Commit caf55abf authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-74413 phpunit: Move more tests to use correct names and namespaces

Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
parent 941a2992
......@@ -13,24 +13,24 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the {@link filter_mathjaxloader_filtermath_testcase} class.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2018 Markku Riekkinen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace filter_mathjaxloader;
use filter_mathjaxloader;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot.'/filter/mathjaxloader/filter.php');
/**
* Unit tests for the MathJax loader filter.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2018 Markku Riekkinen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class filter_mathjaxloader_filtermath_testcase extends advanced_testcase {
class filtermath_test extends \advanced_testcase {
/**
* Test the functionality of {@link filter_mathjaxloader::filter()}.
......@@ -41,7 +41,7 @@ class filter_mathjaxloader_filtermath_testcase extends advanced_testcase {
* @dataProvider test_math_filtering_inputs
*/
public function test_math_filtering($inputtext, $expected) {
$filter = new filter_mathjaxloader(context_system::instance(), []);
$filter = new filter_mathjaxloader(\context_system::instance(), []);
$this->assertEquals($expected, $filter->filter($inputtext));
}
......
......@@ -14,14 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for Marking Guide grading method.
*
* @package gradingform_guide
* @category test
* @copyright 2015 Nikita Kalinin <nixorv@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace gradingform_guide;
use gradingform_controller;
defined('MOODLE_INTERNAL') || die();
......@@ -37,7 +32,7 @@ require_once($CFG->dirroot . '/grade/grading/form/guide/lib.php');
* @copyright 2015 Nikita Kalinin <nixorv@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gradingform_guide_testcase extends advanced_testcase {
class guide_test extends \advanced_testcase {
/**
* Unit test to get draft instance and create new instance.
*/
......
......@@ -14,42 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the advanced grading subsystem
*
* @package core_grading
* @category phpunit
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_grading;
use grading_manager;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/grade/grading/lib.php'); // Include the code to test
/**
* Makes protected method accessible for testing purposes
*
* @package core_grading
* @category phpunit
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_grading_manager extends grading_manager {
}
/**
* Test cases for the grading manager API
*
* @package core_grading
* @category phpunit
* @category test
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_grade_grading_manager_testcase extends advanced_testcase {
class grading_manager_test extends \advanced_testcase {
public function test_basic_instantiation() {
$manager1 = get_grading_manager();
......@@ -103,7 +85,7 @@ class core_grade_grading_manager_testcase extends advanced_testcase {
$this->assertEquals('rubric', $gradingman->get_active_method());
// attempting to set an invalid method
$this->expectException(moodle_exception::class);
$this->expectException(\moodle_exception::class);
$gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name');
}
......@@ -115,27 +97,27 @@ class core_grade_grading_manager_testcase extends advanced_testcase {
$UTFfailuremessage = 'A test using UTF-8 characters has failed. Consider updating PHP and PHP\'s PCRE or INTL extensions (MDL-30494)';
$needle = " šašek, \n\n \r a král; \t";
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(2, count($tokens), $UTFfailuremessage);
$this->assertTrue(in_array('šašek', $tokens), $UTFfailuremessage);
$this->assertTrue(in_array('král', $tokens), $UTFfailuremessage);
$needle = ' " šašek a král " ';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(1, count($tokens));
$this->assertTrue(in_array('šašek a král', $tokens));
$needle = '""';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertTrue(empty($tokens));
$needle = '"0"';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(1, count($tokens));
$this->assertTrue(in_array('0', $tokens));
$needle = '<span>Aha</span>, then who\'s a bad guy here he?';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(8, count($tokens));
$this->assertTrue(in_array('span', $tokens)); // Extracted the tag name
$this->assertTrue(in_array('Aha', $tokens));
......@@ -144,7 +126,7 @@ class core_grade_grading_manager_testcase extends advanced_testcase {
$this->assertTrue(in_array('he', $tokens)); // Removed the trailing ?
$needle = 'grammar, "english language"';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertTrue(in_array('grammar', $tokens));
$this->assertTrue(in_array('english', $tokens));
$this->assertTrue(in_array('language', $tokens));
......
......@@ -14,14 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the class in load_data.php
*
* @package gradeimport_csv
* @category phpunit
* @copyright 2014 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace gradeimport_csv;
defined('MOODLE_INTERNAL') || die();
......@@ -38,7 +31,7 @@ require_once($CFG->libdir . '/grade/tests/fixtures/lib.php');
* @copyright 2014 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gradeimport_csv_load_data_testcase extends grade_base_testcase {
class load_data_test extends \grade_base_testcase {
/** @var string $oktext Text to be imported. This data should have no issues being imported. */
protected $oktext = '"First name",Surname,"ID number",Institution,Department,"Email address","Assignment: Assignment for grape group", "Feedback: Assignment for grape group","Assignment: Second new grade item","Course total"
......@@ -76,8 +69,8 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
*/
protected function csv_load($content) {
// Import the csv strings.
$this->iid = csv_import_reader::get_new_iid('grade');
$this->csvimport = new csv_import_reader($this->iid, 'grade');
$this->iid = \csv_import_reader::get_new_iid('grade');
$this->csvimport = new \csv_import_reader($this->iid, 'grade');
$this->csvimport->load_csv_content($content, 'utf8', 'comma');
$this->columns = $this->csvimport->get_columns();
......@@ -97,7 +90,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$encoding = 'utf8';
$separator = 'comma';
$previewrows = 5;
$csvpreview = new phpunit_gradeimport_csv_load_data();
$csvpreview = new \phpunit_gradeimport_csv_load_data();
$csvpreview->load_csv_content($this->oktext, $encoding, $separator, $previewrows);
$expecteddata = array(array(
......@@ -144,7 +137,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$this->assertEquals($csvpreview->get_headers(), $expectedheaders);
// Check that errors are being recorded.
$csvpreview = new phpunit_gradeimport_csv_load_data();
$csvpreview = new \phpunit_gradeimport_csv_load_data();
$csvpreview->load_csv_content($this->badtext, $encoding, $separator, $previewrows);
// Columns shouldn't match.
$this->assertEquals($csvpreview->get_error(), get_string('csvweirdcolumns', 'error'));
......@@ -155,8 +148,8 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
*/
public function test_fetch_grade_items() {
$gradeitemsarray = grade_item::fetch_all(array('courseid' => $this->courseid));
$gradeitems = phpunit_gradeimport_csv_load_data::fetch_grade_items($this->courseid);
$gradeitemsarray = \grade_item::fetch_all(array('courseid' => $this->courseid));
$gradeitems = \phpunit_gradeimport_csv_load_data::fetch_grade_items($this->courseid);
// Make sure that each grade item is located in the gradeitemsarray.
foreach ($gradeitems as $key => $gradeitem) {
......@@ -187,13 +180,13 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$user = $this->getDataGenerator()->create_user();
$this->setAdminUser();
$record = new stdClass();
$record = new \stdClass();
$record->itemid = 4;
$record->newgradeitem = 25;
$record->finalgrade = 62.00;
$record->feedback = 'Some test feedback';
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$testobject->test_insert_grade_record($record, $user->id);
$gradeimportvalues = $DB->get_records('grade_import_values');
......@@ -201,7 +194,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$key = key($gradeimportvalues);
$testarray = array();
$testarray[$key] = new stdClass();
$testarray[$key] = new \stdClass();
$testarray[$key]->id = $key;
$testarray[$key]->itemid = $record->itemid;
$testarray[$key]->newgradeitem = $record->newgradeitem;
......@@ -228,7 +221,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
// The assignment is item 6.
$key = 6;
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
// Key for this assessment.
$this->csvimport->init();
......@@ -329,7 +322,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
'label' => 'Field label: ' . $field
];
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
// Check whether the user exists. If so, then the user id is returned. Otherwise, it returns null.
$userid = $testobject->test_check_user_exists($value, $userfields);
......@@ -367,7 +360,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
public function test_create_feedback() {
$testarray = $this->csv_load($this->oktext);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
// Try to insert some feedback for an assessment.
$feedback = $testobject->test_create_feedback($this->courseid, 1, $testarray[0][7]);
......@@ -383,7 +376,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
public function test_update_grade_item() {
$testarray = $this->csv_load($this->oktext);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
// We're not using scales so no to this option.
$verbosescales = 0;
......@@ -394,7 +387,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$newgrades = $testobject->test_update_grade_item($this->courseid, $map, $key, $verbosescales, $testarray[0][6]);
$expectedresult = array();
$expectedresult[0] = new stdClass();
$expectedresult[0] = new \stdClass();
$expectedresult[0]->itemid = 1;
$expectedresult[0]->finalgrade = $testarray[0][6];
......@@ -415,14 +408,14 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
*/
public function test_map_user_data_with_value() {
// Need to add one of the users into the system.
$user = new stdClass();
$user = new \stdClass();
$user->firstname = 'Anne';
$user->lastname = 'Able';
$user->email = 'student7@example.com';
$userdetail = $this->getDataGenerator()->create_user($user);
$testarray = $this->csv_load($this->oktext);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
// We're not using scales so no to this option.
$verbosescales = 0;
......@@ -452,7 +445,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$this->courseid, $map[$key], $verbosescales);
// Expected result.
$resultarray = array();
$resultarray[0] = new stdClass();
$resultarray[0] = new \stdClass();
$resultarray[0]->itemid = 1;
$resultarray[0]->feedback = $testarray[0][7];
$this->assertEquals($feedback, $resultarray);
......@@ -470,13 +463,13 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
global $DB;
// Need to add one of the users into the system.
$user = new stdClass();
$user = new \stdClass();
$user->firstname = 'Anne';
$user->lastname = 'Able';
$user->email = 'student7@example.com';
// Insert user 1.
$this->getDataGenerator()->create_user($user);
$user = new stdClass();
$user = new \stdClass();
$user->firstname = 'Bobby';
$user->lastname = 'Bunce';
$user->email = 'student5@example.com';
......@@ -489,7 +482,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$verbosescales = 0;
// Form data object.
$formdata = new stdClass();
$formdata = new \stdClass();
$formdata->mapfrom = 5;
$formdata->mapto = 'useremail';
$formdata->mapping_0 = 0;
......@@ -509,7 +502,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$formdata->forceimport = false;
// Blam go time.
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport, $this->courseid, '', '',
$verbosescales);
// If everything inserted properly then this should be true.
......@@ -522,13 +515,13 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
public function test_force_import_option () {
// Need to add users into the system.
$user = new stdClass();
$user = new \stdClass();
$user->firstname = 'Anne';
$user->lastname = 'Able';
$user->email = 'student7@example.com';
$user->id_number = 1;
$user1 = $this->getDataGenerator()->create_user($user);
$user = new stdClass();
$user = new \stdClass();
$user->firstname = 'Bobby';
$user->lastname = 'Bunce';
$user->email = 'student5@example.com';
......@@ -542,14 +535,14 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
'gradetype' => GRADE_TYPE_VALUE,
'courseid' => $this->courseid
);
$gradeitem = new grade_item($params, false);
$gradeitem = new \grade_item($params, false);
$gradeitemid = $gradeitem->insert();
$importcode = 001;
$verbosescales = 0;
// Form data object.
$formdata = new stdClass();
$formdata = new \stdClass();
$formdata->mapfrom = 5;
$formdata->mapto = 'useremail';
$formdata->mapping_0 = 0;
......@@ -572,7 +565,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$exportdate = time();
$newcsvdata = str_replace('{exportdate}', $exportdate, $this->csvtext);
$this->csv_load($newcsvdata);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertTrue($dataloaded);
......@@ -584,7 +577,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$pastdate = strtotime('-1 day', time());
$newcsvdata = str_replace('{exportdate}', $pastdate, $this->csvtext);
$this->csv_load($newcsvdata);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertFalse($dataloaded);
......@@ -593,7 +586,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
// Test using force import enabled and a date in the past.
$formdata->forceimport = true;
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertTrue($dataloaded);
......@@ -603,7 +596,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$twoyearsago = strtotime('-2 year', time());
$newcsvdata = str_replace('{exportdate}', $twoyearsago, $this->csvtext);
$this->csv_load($newcsvdata);
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertFalse($dataloaded);
......@@ -615,7 +608,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$newcsvdata = str_replace('{exportdate}', $baddate, $this->csvtext);
$this->csv_load($newcsvdata);
$formdata->mapping_6 = $gradeitemid;
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertFalse($dataloaded);
......@@ -627,7 +620,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
$oldcsv = str_replace('{exportdate}', $oneyearahead, $this->csvtext);
$this->csv_load($oldcsv);
$formdata->mapping_6 = $gradeitemid;
$testobject = new phpunit_gradeimport_csv_load_data();
$testobject = new \phpunit_gradeimport_csv_load_data();
$dataloaded = $testobject->prepare_import_grade_data($this->columns, $formdata, $this->csvimport,
$this->courseid, '', '', $verbosescales);
$this->assertFalse($dataloaded);
......
......@@ -14,26 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for gradereport_singleview screen class.
*
* @package gradereport_singleview
* @category test
* @copyright 2014 onwards Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace gradereport_singleview;
use gradereport_singleview_screen_testable;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once(__DIR__ . '/fixtures/screen.php');
require_once($CFG->libdir . '/gradelib.php');
defined('MOODLE_INTERNAL') || die();
/**
* Tests for screen class.
*
* Class gradereport_singleview_screen_testcase.
* @package gradereport_singleview
* @category test
* @copyright 2014 onwards Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gradereport_singleview_screen_testcase extends advanced_testcase {
class screen_test extends \advanced_testcase {
/**
* Test load_users method.
......@@ -48,7 +47,7 @@ class gradereport_singleview_screen_testcase extends advanced_testcase {
// Create a course, users and groups.
$course = $this->getDataGenerator()->create_course();
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
$group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
$teacher = $this->getDataGenerator()->create_user();
$user1 = $this->getDataGenerator()->create_user();
......
......@@ -14,25 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for grade/edit/tree/lib.php.
*
* @package core_grades
* @category phpunit
* @author Andrew Davis
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
namespace core_grades;
use grade_edit_tree;
use grade_edit_tree_column;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot.'/grade/edit/tree/lib.php');
/**
* Tests grade_edit_tree (deals with the data on the 'Gradebook setup' page in the gradebook)
*
* @package core_grades
* @category test
* @author Andrew Davis
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
class core_grade_edittreelib_testcase extends advanced_testcase {
class edittreelib_test extends \advanced_testcase {
public function test_format_number() {
$numinput = array(0, 1, 1.01, '1.010', 1.2345);
$numoutput = array(0.0, 1.0, 1.01, 1.01, 1.2345);
......@@ -52,9 +52,9 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
$scale = $this->getDataGenerator()->create_scale();
$course = $this->getDataGenerator()->create_course();
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
$modulecontext = context_module::instance($assign->cmid);
$modulecontext = \context_module::instance($assign->cmid);
// The generator returns a dummy object, lets get the real assign object.
$assign = new assign($modulecontext, false, false);
$assign = new \assign($modulecontext, false, false);
$cm = $assign->get_course_module();
// Get range column.
......@@ -74,7 +74,7 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
$instance->instance = $instance->id;
$assign->update_instance($instance);
$gradeitem = grade_item::fetch($gradeitemparams);
$gradeitem = \grade_item::fetch($gradeitemparams);
$cell = $column->get_item_cell($gradeitem, array());
$this->assertEquals(GRADE_TYPE_VALUE, $gradeitem->gradetype);
......@@ -87,7 +87,7 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
$instance->instance = $instance->id;
$assign->update_instance($instance);
$gradeitem = grade_item::fetch($gradeitemparams);
$gradeitem = \grade_item::fetch($gradeitemparams);
$cell = $column->get_item_cell($gradeitem, array());
// Make the expected scale text.
......@@ -113,7 +113,7 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
$instance->instance = $instance->id;
$assign->update_instance($instance);
$gradeitem = grade_item::fetch($gradeitemparams);
$gradeitem = \grade_item::fetch($gradeitemparams);
$cell = $column->get_item_cell($gradeitem, array());
$this->assertEquals(GRADE_TYPE_TEXT, $gradeitem->gradetype);
......@@ -127,7 +127,7 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
$instance->instance = $instance->id;
$assign->update_instance($instance);
$gradeitem = grade_item::fetch($gradeitemparams);
$gradeitem = \grade_item::fetch($gradeitemparams);
$cell = $column->get_item_cell($gradeitem, array());
$this->assertEquals(GRADE_TYPE_NONE, $gradeitem->gradetype);
......
......@@ -14,14 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for grade/report/lib.php.
*
* @package core_grades
* @category phpunit
* @copyright Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
namespace core_grades;
defined('MOODLE_INTERNAL') || die();
......@@ -31,8 +24,13 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
/**
* A test class used to test grade_report, the abstract grade report parent class
*
* @package core_grades
* @category test
* @copyright Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
class core_grade_export_test extends advanced_testcase {
class export_test extends \advanced_testcase {
/**
* Ensure that feedback is correct formatted. Test the default implementation of format_feedback
......@@ -67,7 +65,7 @@ class core_grade_export_test extends advanced_testcase {
$dg = $this->getDataGenerator();
$c1 = $dg->create_course();
$u1 = $dg->create_user();
$gi1a = new grade_item($dg->create_grade_item(['courseid' => $c1->id]), false);
$gi1a = new \grade_item($dg->create_grade_item(['courseid' => $c1->id]), false);
$gi1a->update_final_grade($u1->id, 1, 'test');
$contextid = $gi1a->get_context()->id;
$gradeid = $gi1a->id;
......
......@@ -14,14 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for grade/import/lib.php.