Commit 511801cb authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-73352 phpunit: lib_test and locallib_test testcase names

All lib_test and locallib_test classes:

- Namespaced with component (and API whenever makes sense).
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed or add new uses.
- All them passing individually.
- Complete runs passing too.

Special mention to tests under login/tests:

1) The core_login component doesn't exist.
2) But login/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have login_xxxx as prefix.
parent 541d999d
......@@ -21,6 +21,7 @@
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
namespace tool_capability;
defined('MOODLE_INTERNAL') || die();
global $CFG;
......@@ -30,7 +31,7 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/capability/locallib.php'
/**
* Tests for the capability overview helper functions.
*/
class tool_capability_locallib_testcase extends advanced_testcase {
class locallib_test extends \advanced_testcase {
/**
* Test the function that gets the data - simple case.
......@@ -40,7 +41,7 @@ class tool_capability_locallib_testcase extends advanced_testcase {
$data = tool_capability_calculate_role_data('mod/quiz:attempt', get_all_roles());
$systcontext = context_system::instance();
$systcontext = \context_system::instance();
$studentroleid = $DB->get_field('role', 'id', ['shortname' => 'student']);
$this->assertArrayHasKey($systcontext->id, $data);
......@@ -63,10 +64,10 @@ class tool_capability_locallib_testcase extends advanced_testcase {
// This simulates a situation that seems to happen sometimes, where
// we end up with contexts with path = NULL in the database.
$systcontext = context_system::instance();
$systcontext = \context_system::instance();
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
$studentroleid = $DB->get_field('role', 'id', ['shortname' => 'student']);
role_change_permission($studentroleid, $coursecontext, 'mod/quiz:attempt', CAP_PREVENT);
// This is where we simulate the breakage.
......
......@@ -21,6 +21,7 @@
* @copyright 2020 Peter Dias
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_moodlenet;
defined('MOODLE_INTERNAL') || die();
......@@ -30,7 +31,7 @@ require_once($CFG->dirroot . '/admin/tool/moodlenet/lib.php');
/**
* Test moodlenet functions
*/
class tool_moodlenet_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
/**
* Test the generate_mnet_endpoint function
......
......@@ -22,6 +22,9 @@
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_blog;
use blog_listing;
defined('MOODLE_INTERNAL') || die();
......@@ -32,7 +35,7 @@ require_once($CFG->dirroot . '/blog/lib.php');
/**
* Test functions that rely on the DB tables
*/
class core_blog_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
private $courseid;
private $cmid;
......@@ -54,7 +57,7 @@ class core_blog_lib_testcase extends advanced_testcase {
$this->assertNotEmpty($page);
// Create default group.
$group = new stdClass();
$group = new \stdClass();
$group->courseid = $course->id;
$group->name = 'ANON';
$group->id = $DB->insert_record('groups', $group);
......@@ -71,7 +74,7 @@ class core_blog_lib_testcase extends advanced_testcase {
'rawname' => 'Testtagname', 'isstandard' => 1));
// Create default post.
$post = new stdClass();
$post = new \stdClass();
$post->userid = $user->id;
$post->groupid = $group->id;
$post->content = 'test post content text';
......@@ -170,7 +173,7 @@ class core_blog_lib_testcase extends advanced_testcase {
// Check the node tree is correct.
core_blog_myprofile_navigation($tree, $USER, $iscurrentuser, $course);
$reflector = new ReflectionObject($tree);
$reflector = new \ReflectionObject($tree);
$nodes = $reflector->getProperty('nodes');
$nodes->setAccessible(true);
$this->assertArrayHasKey('blogs', $nodes->getValue($tree));
......@@ -192,7 +195,7 @@ class core_blog_lib_testcase extends advanced_testcase {
// Check the node tree is correct.
core_blog_myprofile_navigation($tree, $USER, $iscurrentuser, $course);
$reflector = new ReflectionObject($tree);
$reflector = new \ReflectionObject($tree);
$nodes = $reflector->getProperty('nodes');
$nodes->setAccessible(true);
$this->assertArrayNotHasKey('blogs', $nodes->getValue($tree));
......@@ -215,7 +218,7 @@ class core_blog_lib_testcase extends advanced_testcase {
// Check the node tree is correct.
core_blog_myprofile_navigation($tree, $USER, $iscurrentuser, $course);
$reflector = new ReflectionObject($tree);
$reflector = new \ReflectionObject($tree);
$nodes = $reflector->getProperty('nodes');
$nodes->setAccessible(true);
$this->assertArrayNotHasKey('blogs', $nodes->getValue($tree));
......@@ -223,11 +226,11 @@ class core_blog_lib_testcase extends advanced_testcase {
public function test_blog_get_listing_course() {
$this->setAdminUser();
$coursecontext = context_course::instance($this->courseid);
$coursecontext = \context_course::instance($this->courseid);
$anothercourse = $this->getDataGenerator()->create_course();
// Add blog associations with a course.
$blog = new blog_entry($this->postid);
$blog = new \blog_entry($this->postid);
$blog->add_association($coursecontext->id);
// There is one entry associated with a course.
......@@ -253,12 +256,12 @@ class core_blog_lib_testcase extends advanced_testcase {
public function test_blog_get_listing_module() {
$this->setAdminUser();
$coursecontext = context_course::instance($this->courseid);
$contextmodule = context_module::instance($this->cmid);
$coursecontext = \context_course::instance($this->courseid);
$contextmodule = \context_module::instance($this->cmid);
$anothermodule = $this->getDataGenerator()->create_module('page', array('course' => $this->courseid));
// Add blog associations with a course.
$blog = new blog_entry($this->postid);
$blog = new \blog_entry($this->postid);
$blog->add_association($contextmodule->id);
// There is no entry associated with a course.
......
......@@ -21,6 +21,7 @@
* @copyright 2017 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_calendar;
defined('MOODLE_INTERNAL') || die();
......@@ -33,7 +34,7 @@ require_once(__DIR__ . '/helpers.php');
* @copyright 2017 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_calendar_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
/**
* Tests set up
......@@ -89,7 +90,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
]
];
foreach ($events as $event) {
calendar_event::create($event, false);
\calendar_event::create($event, false);
}
$timestart = time() - 60;
$timeend = time() + 60;
......@@ -145,7 +146,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
public function test_update_subscription() {
$this->resetAfterTest(true);
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->eventtype = 'site';
$subscription->name = 'test';
$id = calendar_add_subscription($subscription);
......@@ -164,7 +165,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$this->assertEquals($subscription->name, $sub->name);
$this->assertEquals($subscription->pollinterval, $sub->pollinterval);
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->name = 'awesome4';
$this->expectException('coding_exception');
calendar_update_subscription($subscription);
......@@ -178,14 +179,14 @@ class core_calendar_lib_testcase extends advanced_testcase {
$this->resetAfterTest(true);
// Test for Microsoft Outlook 2010.
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->name = 'Microsoft Outlook 2010';
$subscription->importfrom = CALENDAR_IMPORT_FROM_FILE;
$subscription->eventtype = 'site';
$id = calendar_add_subscription($subscription);
$calendar = file_get_contents($CFG->dirroot . '/lib/tests/fixtures/ms_outlook_2010.ics');
$ical = new iCalendar();
$ical = new \iCalendar();
$ical->unserialize($calendar);
$this->assertEquals($ical->parser_errors, array());
......@@ -195,14 +196,14 @@ class core_calendar_lib_testcase extends advanced_testcase {
$this->assertEquals($count, 1);
// Test for OSX Yosemite.
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->name = 'OSX Yosemite';
$subscription->importfrom = CALENDAR_IMPORT_FROM_FILE;
$subscription->eventtype = 'site';
$id = calendar_add_subscription($subscription);
$calendar = file_get_contents($CFG->dirroot . '/lib/tests/fixtures/osx_yosemite.ics');
$ical = new iCalendar();
$ical = new \iCalendar();
$ical->unserialize($calendar);
$this->assertEquals($ical->parser_errors, array());
......@@ -212,14 +213,14 @@ class core_calendar_lib_testcase extends advanced_testcase {
$this->assertEquals($count, 1);
// Test for Google Gmail.
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->name = 'Google Gmail';
$subscription->importfrom = CALENDAR_IMPORT_FROM_FILE;
$subscription->eventtype = 'site';
$id = calendar_add_subscription($subscription);
$calendar = file_get_contents($CFG->dirroot . '/lib/tests/fixtures/google_gmail.ics');
$ical = new iCalendar();
$ical = new \iCalendar();
$ical->unserialize($calendar);
$this->assertEquals($ical->parser_errors, array());
......@@ -229,13 +230,13 @@ class core_calendar_lib_testcase extends advanced_testcase {
$this->assertEquals($count, 1);
// Test for ICS file with repeated events.
$subscription = new stdClass();
$subscription = new \stdClass();
$subscription->name = 'Repeated events';
$subscription->importfrom = CALENDAR_IMPORT_FROM_FILE;
$subscription->eventtype = 'site';
$id = calendar_add_subscription($subscription);
$calendar = file_get_contents($CFG->dirroot . '/lib/tests/fixtures/repeated_events.ics');
$ical = new iCalendar();
$ical = new \iCalendar();
$ical->unserialize($calendar);
$this->assertEquals($ical->parser_errors, []);
......@@ -356,7 +357,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
];
foreach ($events as $event) {
calendar_event::create($event, false);
\calendar_event::create($event, false);
}
$timestart = $now - 100;
......@@ -432,7 +433,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
];
foreach ($repeatingevents as $event) {
calendar_event::create($event, false);
\calendar_event::create($event, false);
}
// Make sure repeating events are not filtered out.
......@@ -450,7 +451,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$course1 = $generator->create_course();
$course2 = $generator->create_course();
$course3 = $generator->create_course();
$context = context_course::instance($course1->id);
$context = \context_course::instance($course1->id);
$this->setAdminUser();
$admin = clone $USER;
......@@ -551,9 +552,9 @@ class core_calendar_lib_testcase extends advanced_testcase {
$course1 = $generator->create_course(); // Has capability.
$course2 = $generator->create_course(); // Doesn't have capability.
$course3 = $generator->create_course(); // Not enrolled.
$context1 = context_course::instance($course1->id);
$context2 = context_course::instance($course2->id);
$context3 = context_course::instance($course3->id);
$context1 = \context_course::instance($course1->id);
$context2 = \context_course::instance($course2->id);
$context3 = \context_course::instance($course3->id);
$roleid = $generator->create_role();
$contexts = [$context1, $context2, $context3];
$enrolledcourses = [$course1, $course2];
......@@ -600,7 +601,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$roleid = $generator->create_role();
$generator->enrol_user($user->id, $course->id, 'student');
......@@ -627,7 +628,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$roleid = $generator->create_role();
$generator->enrol_user($user->id, $course->id, 'student');
$generator->role_assign($roleid, $user->id, $context->id);
......@@ -652,8 +653,8 @@ class core_calendar_lib_testcase extends advanced_testcase {
$course2 = $generator->create_course();
$generator->create_group(array('courseid' => $course1->id));
$generator->create_group(array('courseid' => $course2->id));
$context1 = context_course::instance($course1->id);
$context2 = context_course::instance($course2->id);
$context1 = \context_course::instance($course1->id);
$context2 = \context_course::instance($course2->id);
$roleid = $generator->create_role();
$generator->enrol_user($user->id, $course1->id, 'student');
$generator->enrol_user($user->id, $course2->id, 'student');
......@@ -678,7 +679,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$group1 = $generator->create_group(array('courseid' => $course->id));
$group2 = $generator->create_group(array('courseid' => $course->id));
$roleid = $generator->create_role();
......@@ -711,7 +712,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$roleid = $generator->create_role();
$group = $generator->create_group(['courseid' => $course->id]);
$generator->enrol_user($user->id, $course->id, 'student');
......@@ -733,7 +734,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$roleid = $generator->create_role();
$group = $generator->create_group(['courseid' => $course->id]);
$generator->enrol_user($user->id, $course->id, 'student');
......@@ -756,7 +757,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$roleid = $generator->create_role();
$group = $generator->create_group(['courseid' => $course->id]);
$generator->enrol_user($user->id, $course->id, 'student');
......@@ -941,13 +942,13 @@ class core_calendar_lib_testcase extends advanced_testcase {
'timeduration' => 86400,
'visible' => 1
];
$caleventmanual = calendar_event::create($manualevent, false);
$caleventmanual = \calendar_event::create($manualevent, false);
// Create a course event for the course with guest access.
$guestevent = clone $manualevent;
$guestevent->name = 'Guest course event';
$guestevent->courseid = $guestcourse->id;
$caleventguest = calendar_event::create($guestevent, false);
$caleventguest = \calendar_event::create($guestevent, false);
// Viewing as admin.
$this->assertTrue(calendar_view_event_allowed($caleventmanual));
......
......@@ -21,6 +21,7 @@
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_competency;
defined('MOODLE_INTERNAL') || die();
......@@ -37,7 +38,7 @@ global $CFG;
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_competency_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
public function test_comment_add_user_competency() {
global $DB, $PAGE;
......@@ -49,11 +50,11 @@ class core_competency_lib_testcase extends advanced_testcase {
$u2 = $dg->create_user();
$u3 = $dg->create_user();
$reviewerroleid = $dg->create_role();
assign_capability('moodle/competency:planview', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planview', CAP_ALLOW, $reviewerroleid, \context_system::instance()->id, true);
assign_capability('moodle/competency:usercompetencycomment', CAP_ALLOW, $reviewerroleid,
context_system::instance()->id, true);
$dg->role_assign($reviewerroleid, $u2->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, context_user::instance($u1->id));
\context_system::instance()->id, true);
$dg->role_assign($reviewerroleid, $u2->id, \context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, \context_user::instance($u1->id));
accesslib_clear_all_caches_for_unit_testing();
$f1 = $lpg->create_framework();
......@@ -89,7 +90,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$expectedurlname = $c1->get('shortname');
$expectedurl = url::user_competency_in_plan($u1->id, $c1->get('id'), $p1->get('id'));
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u2->id, $message->useridto);
$this->assertTrue(strpos($message->fullmessage, 'Hello world!') !== false);
$this->assertTrue(strpos($message->fullmessagehtml, 'Hello world!') !== false);
......@@ -117,7 +118,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$expectedurlname = $c2->get('shortname');
$expectedurl = url::user_competency_in_plan($u1->id, $c2->get('id'), $p2->get('id'));
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message->useridto);
$this->assertTrue(strpos($message->fullmessage, 'Hello world!') !== false);
$this->assertTrue(strpos($message->fullmessagehtml, 'Hello world!') !== false);
......@@ -137,7 +138,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$expectedurlname = get_string('userplans', 'core_competency');
$expectedurl = url::plans($u1->id);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message->useridto);
$this->assertTrue(strpos($message->fullmessage, 'Hello world!') !== false);
$this->assertTrue(strpos($message->fullmessagehtml, 'Hello world!') !== false);
......@@ -155,9 +156,9 @@ class core_competency_lib_testcase extends advanced_testcase {
$this->assertCount(2, $messages);
$message1 = array_shift($messages);
$message2 = array_shift($messages);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message1->useridto);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u2->id, $message2->useridto);
// A comment is posted in HTML.
......@@ -172,7 +173,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$expectedurlname = get_string('userplans', 'core_competency');
$expectedurl = url::plans($u1->id);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message->useridto);
$this->assertTrue(strpos($message->fullmessage, '<em>Hello world!</em>') !== false);
$this->assertTrue(strpos($message->fullmessagehtml, '<em>Hello world!</em>') !== false);
......@@ -194,14 +195,14 @@ class core_competency_lib_testcase extends advanced_testcase {
$u3 = $dg->create_user();
$userroleid = $dg->create_role();
$reviewerroleid = $dg->create_role();
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
$dg->role_assign($userroleid, $u1->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u2->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, context_system::instance());
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $userroleid, \context_system::instance()->id, true);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $userroleid, \context_system::instance()->id, true);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $reviewerroleid, \context_system::instance()->id, true);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $reviewerroleid, \context_system::instance()->id, true);
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $reviewerroleid, \context_system::instance()->id, true);
$dg->role_assign($userroleid, $u1->id, \context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u2->id, \context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, \context_system::instance());
accesslib_clear_all_caches_for_unit_testing();
$p1 = $lpg->create_plan(array('userid' => $u1->id));
......@@ -224,7 +225,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$sink->close();
$this->assertCount(1, $messages);
$message = array_pop($messages);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message->useridto);
// Test customdata.
$customdata = json_decode($message->customdata);
......@@ -241,7 +242,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$sink->close();
$this->assertCount(1, $messages);
$message = array_pop($messages);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u2->id, $message->useridto);
// Post a comment as reviewer in a plan being reviewed. The owner is messaged.
......@@ -255,7 +256,7 @@ class core_competency_lib_testcase extends advanced_testcase {
$sink->close();
$this->assertCount(1, $messages);
$message = array_pop($messages);
$this->assertEquals(core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message->useridfrom);
$this->assertEquals($u1->id, $message->useridto);
// Post a comment as someone else in a plan being reviewed. The owner and reviewer are messaged.
......@@ -270,9 +271,9 @@ class core_competency_lib_testcase extends advanced_testcase {
$this->assertCount(2, $messages);
$message1 = array_shift($messages);
$message2 = array_shift($messages);
$this->assertEquals(core_user::get_noreply_user()->id, $message1->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message1->useridfrom);
$this->assertEquals($u1->id, $message1->useridto);
$this->assertEquals(core_user::get_noreply_user()->id, $message2->useridfrom);
$this->assertEquals(\core_user::get_noreply_user()->id, $message2->useridfrom);
$this->assertEquals($u2->id, $message2->useridto);
$p1->set('reviewerid', null);
......
......@@ -21,6 +21,9 @@
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace enrol_database;
use course_enrolment_manager;
defined('MOODLE_INTERNAL') || die();
......@@ -32,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_database_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
/**
* Test for getting user enrolment actions.
*/
......
......@@ -21,7 +21,10 @@
* @copyright 2016 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace enrol_lti;
use course_enrolment_manager;
use enrol_lti_plugin;
use enrol_lti\data_connector;
use enrol_lti\tool_provider;
use IMSGlobal\LTI\ToolProvider\ResourceLink;
......@@ -38,7 +41,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2016 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_lti_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
/**
* Test set up.
......@@ -57,7 +60,7 @@ class enrol_lti_testcase extends advanced_testcase {
global $DB;
// Create tool enrolment instance.
$data = new stdClass();
$data = new \stdClass();
$data->enrolstartdate = time();
$data->secret = 'secret';
$tool = $this->getDataGenerator()->create_lti_tool($data);
......@@ -140,7 +143,7 @@ class enrol_lti_testcase extends advanced_testcase {
// Create a course.
$course = $generator->create_course();
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$teacherroleid = $DB->get_field('role', 'id', ['shortname' => 'editingteacher'], MUST_EXIST);
$studentroleid = $DB->get_field('role', 'id', ['shortname' => 'student'], MUST_EXIST);
......
......@@ -22,6 +22,9 @@
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace enrol_manual;
use course_enrolment_manager;
defined('MOODLE_INTERNAL') || die();
......@@ -34,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_manual_lib_testcase extends advanced_testcase {
class lib_test extends \advanced_testcase {
/**
* Test enrol migration function used when uninstalling enrol plugins.
*/
......@@ -60,10 +63,10 @@ class enrol_manual_lib_testcase extends advanced_testcase {
$course4 = $this->getDataGenerator()->create_course();
$course5 = $this->getDataGenerator()->create_course();
$context1 = context_course::instance($course1->id);
$context2 = context_course::instance($course2->id);
$context3 = context_course::instance($course3->id);
$context4 = context_course::instance($course4->id);
$context1 = \context_course::instance($course1->id);
$context2 = \context_course::instance($course2->id);
$context3 = \context_course::instance($course3->id);
$context4 = \context_course::instance($course4->id);
$user1 = $this->getDataGenerator()->create_user();
$user2 = $this->getDataGenerator()->create_user();
......@@ -210,7 +213,7 @@ class enrol_manual_lib_testcase extends advanced_testcase {
/** @var $manualplugin enrol_manual_plugin */
$manualplugin = enrol_get_plugin('manual');
$trace = new null_progress_trace();
$trace = new \null_progress_trace();
$now = time();
......@@ -231,9 +234,9 @@ class enrol_manual_lib_testcase extends advanced_testcase {
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$course3 = $this->getDataGenerator()->create_course();