Merge branch 'MDL-73352' of https://github.com/stronk7/moodle
This commit is contained in:
@@ -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
|
||||
|
||||
+14
-11
@@ -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.
|
||||
|
||||
+29
-28
@@ -21,6 +21,7 @@
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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();
|
||||
$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);
|
||||
|
||||
$this->assertEquals(3, $DB->count_records('enrol', array('enrol'=>'manual')));
|
||||
$instance1 = $DB->get_record('enrol', array('courseid'=>$course1->id, 'enrol'=>'manual'), '*', MUST_EXIST);
|
||||
@@ -335,7 +338,7 @@ class enrol_manual_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->preventResetByRollback(); // Messaging does not like transactions...
|
||||
|
||||
$trace = new null_progress_trace();
|
||||
$trace = new \null_progress_trace();
|
||||
|
||||
/** @var $manualplugin enrol_manual_plugin */
|
||||
$manualplugin = enrol_get_plugin('manual');
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2015 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace gradereport_user;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +35,7 @@ require_once($CFG->dirroot . '/grade/report/user/lib.php');
|
||||
* @copyright 2015 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class gradereport_user_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -66,7 +67,7 @@ class gradereport_user_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = false;
|
||||
|
||||
gradereport_user_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('grade', $nodes->getValue($this->tree));
|
||||
@@ -81,7 +82,7 @@ class gradereport_user_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = true;
|
||||
|
||||
gradereport_user_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('grade', $nodes->getValue($this->tree));
|
||||
|
||||
+20
-19
@@ -22,6 +22,7 @@
|
||||
* @copyright 2016 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
namespace core_grades;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ require_once($CFG->dirroot . '/grade/lib.php');
|
||||
* @copyright 2016 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_grade_lib_test extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test can_output_item.
|
||||
@@ -50,18 +51,18 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
$course = $generator->create_course();
|
||||
// Grade tree looks something like:
|
||||
// - Test course (Rendered).
|
||||
$gradetree = grade_category::fetch_course_tree($course->id);
|
||||
$this->assertTrue(grade_tree::can_output_item($gradetree));
|
||||
$gradetree = \grade_category::fetch_course_tree($course->id);
|
||||
$this->assertTrue(\grade_tree::can_output_item($gradetree));
|
||||
|
||||
// Add a grade category with default settings.
|
||||
$generator->create_grade_category(array('courseid' => $course->id));
|
||||
// Grade tree now looks something like:
|
||||
// - Test course n (Rendered).
|
||||
// -- Grade category n (Rendered).
|
||||
$gradetree = grade_category::fetch_course_tree($course->id);
|
||||
$gradetree = \grade_category::fetch_course_tree($course->id);
|
||||
$this->assertNotEmpty($gradetree['children']);
|
||||
foreach ($gradetree['children'] as $child) {
|
||||
$this->assertTrue(grade_tree::can_output_item($child));
|
||||
$this->assertTrue(\grade_tree::can_output_item($child));
|
||||
}
|
||||
|
||||
// Add a grade category with grade type = None.
|
||||
@@ -72,7 +73,7 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
'aggregation' => GRADE_AGGREGATE_WEIGHTED_MEAN
|
||||
];
|
||||
$nototal = $generator->create_grade_category($nototalparams);
|
||||
$catnototal = grade_category::fetch(array('id' => $nototal->id));
|
||||
$catnototal = \grade_category::fetch(array('id' => $nototal->id));
|
||||
// Set the grade type of the grade item associated to the grade category.
|
||||
$catitemnototal = $catnototal->load_grade_item();
|
||||
$catitemnototal->gradetype = GRADE_TYPE_NONE;
|
||||
@@ -82,12 +83,12 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
// - Test course n (Rendered).
|
||||
// -- Grade category n (Rendered).
|
||||
// -- No total category (Not rendered).
|
||||
$gradetree = grade_category::fetch_course_tree($course->id);
|
||||
$gradetree = \grade_category::fetch_course_tree($course->id);
|
||||
foreach ($gradetree['children'] as $child) {
|
||||
if ($child['object']->fullname == $nototalcategory) {
|
||||
$this->assertFalse(grade_tree::can_output_item($child));
|
||||
$this->assertFalse(\grade_tree::can_output_item($child));
|
||||
} else {
|
||||
$this->assertTrue(grade_tree::can_output_item($child));
|
||||
$this->assertTrue(\grade_tree::can_output_item($child));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +105,13 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
// -- Grade category n (Rendered).
|
||||
// -- No total category (Rendered).
|
||||
// --- Normal category in no total category (Rendered).
|
||||
$gradetree = grade_category::fetch_course_tree($course->id);
|
||||
$gradetree = \grade_category::fetch_course_tree($course->id);
|
||||
foreach ($gradetree['children'] as $child) {
|
||||
// All children are now visible.
|
||||
$this->assertTrue(grade_tree::can_output_item($child));
|
||||
$this->assertTrue(\grade_tree::can_output_item($child));
|
||||
if (!empty($child['children'])) {
|
||||
foreach ($child['children'] as $grandchild) {
|
||||
$this->assertTrue(grade_tree::can_output_item($grandchild));
|
||||
$this->assertTrue(\grade_tree::can_output_item($grandchild));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +124,7 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
'aggregation' => GRADE_AGGREGATE_WEIGHTED_MEAN
|
||||
];
|
||||
$nototal2 = $generator->create_grade_category($nototal2params);
|
||||
$catnototal2 = grade_category::fetch(array('id' => $nototal2->id));
|
||||
$catnototal2 = \grade_category::fetch(array('id' => $nototal2->id));
|
||||
// Set the grade type of the grade item associated to the grade category.
|
||||
$catitemnototal2 = $catnototal2->load_grade_item();
|
||||
$catitemnototal2->gradetype = GRADE_TYPE_NONE;
|
||||
@@ -138,7 +139,7 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
'parent' => $nototal2->id
|
||||
];
|
||||
$nototalinnototal = $generator->create_grade_category($nototalinnototalparams);
|
||||
$catnototalinnototal = grade_category::fetch(array('id' => $nototalinnototal->id));
|
||||
$catnototalinnototal = \grade_category::fetch(array('id' => $nototalinnototal->id));
|
||||
// Set the grade type of the grade item associated to the grade category.
|
||||
$catitemnototalinnototal = $catnototalinnototal->load_grade_item();
|
||||
$catitemnototalinnototal->gradetype = GRADE_TYPE_NONE;
|
||||
@@ -151,19 +152,19 @@ class core_grade_lib_test extends advanced_testcase {
|
||||
// --- Normal category in no total category (Rendered).
|
||||
// -- No total category 2 (Not rendered).
|
||||
// --- Category with no total in no total category (Not rendered).
|
||||
$gradetree = grade_category::fetch_course_tree($course->id);
|
||||
$gradetree = \grade_category::fetch_course_tree($course->id);
|
||||
foreach ($gradetree['children'] as $child) {
|
||||
if ($child['object']->fullname == $nototalcategory2) {
|
||||
$this->assertFalse(grade_tree::can_output_item($child));
|
||||
$this->assertFalse(\grade_tree::can_output_item($child));
|
||||
} else {
|
||||
$this->assertTrue(grade_tree::can_output_item($child));
|
||||
$this->assertTrue(\grade_tree::can_output_item($child));
|
||||
}
|
||||
if (!empty($child['children'])) {
|
||||
foreach ($child['children'] as $grandchild) {
|
||||
if ($grandchild['object']->fullname == $nototalinnototalcategory) {
|
||||
$this->assertFalse(grade_tree::can_output_item($grandchild));
|
||||
$this->assertFalse(\grade_tree::can_output_item($grandchild));
|
||||
} else {
|
||||
$this->assertTrue(grade_tree::can_output_item($grandchild));
|
||||
$this->assertTrue(\grade_tree::can_output_item($grandchild));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-32
@@ -21,6 +21,7 @@
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_group;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +35,7 @@ require_once($CFG->dirroot . '/group/lib.php');
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_group_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function test_member_added_event() {
|
||||
$this->resetAfterTest();
|
||||
@@ -51,7 +52,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
$expected = new stdClass();
|
||||
$expected = new \stdClass();
|
||||
$expected->groupid = $group->id;
|
||||
$expected->userid = $user->id;
|
||||
$expected->component = 'mod_workshop';
|
||||
@@ -60,9 +61,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame('groups_member_added', $event->get_legacy_eventname());
|
||||
$this->assertInstanceOf('\core\event\group_member_added', $event);
|
||||
$this->assertEquals($user->id, $event->relateduserid);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/members.php', array('group' => $event->objectid));
|
||||
$url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -82,16 +83,16 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
$expected = new stdClass();
|
||||
$expected = new \stdClass();
|
||||
$expected->groupid = $group->id;
|
||||
$expected->userid = $user->id;
|
||||
$this->assertEventLegacyData($expected, $event);
|
||||
$this->assertSame('groups_member_removed', $event->get_legacy_eventname());
|
||||
$this->assertInstanceOf('\core\event\group_member_removed', $event);
|
||||
$this->assertEquals($user->id, $event->relateduserid);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/members.php', array('group' => $event->objectid));
|
||||
$url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -110,9 +111,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('\core\event\group_created', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_created', $event->get_legacy_eventname());
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
$url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -133,9 +134,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_grouping_created', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
$url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->id = $group->id;
|
||||
$data->courseid = $course->id;
|
||||
$data->name = 'Backend team';
|
||||
@@ -164,9 +165,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$group->name = $data->name;
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_updated', $event->get_legacy_eventname());
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
$url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->id = $group->id;
|
||||
$data->courseid = $course->id;
|
||||
$this->setCurrentTimeStart();
|
||||
@@ -193,9 +194,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('\core\event\group_updated', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_updated', $event->get_legacy_eventname());
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
$url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -208,7 +209,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->id = $grouping->id;
|
||||
$data->courseid = $course->id;
|
||||
$data->name = 'Backend team';
|
||||
@@ -233,9 +234,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertEventLegacyData($data, $event);
|
||||
$this->assertSame('groups_grouping_updated', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($grouping->id, $event->objectid);
|
||||
$url = new moodle_url('/group/grouping.php', array('id' => $event->objectid));
|
||||
$url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -248,7 +249,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->id = $grouping->id;
|
||||
$data->courseid = $course->id;
|
||||
$this->setCurrentTimeStart();
|
||||
@@ -273,9 +274,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertEventLegacyData($data, $event);
|
||||
$this->assertSame('groups_grouping_updated', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($grouping->id, $event->objectid);
|
||||
$url = new moodle_url('/group/grouping.php', array('id' => $event->objectid));
|
||||
$url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -294,9 +295,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('\core\event\group_deleted', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
$url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -315,9 +316,9 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('\core\event\grouping_deleted', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_grouping_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
$url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
}
|
||||
|
||||
@@ -538,7 +539,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = context_course::instance($course1->id);
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
|
||||
// Create two groups and only one group with enablemessaging = 1.
|
||||
$group1a = $this->getDataGenerator()->create_group(array('courseid' => $course1->id, 'enablemessaging' => 1));
|
||||
@@ -576,7 +577,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = context_course::instance($course1->id);
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
|
||||
// Create two groups and only one group with enablemessaging = 1.
|
||||
$group1a = $this->getDataGenerator()->create_group(array('courseid' => $course1->id, 'enablemessaging' => 1));
|
||||
@@ -635,7 +636,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = context_course::instance($course1->id);
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
@@ -678,7 +679,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = context_course::instance($course1->id);
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
@@ -725,7 +726,7 @@ class core_group_lib_testcase extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$coursecontext1 = context_course::instance($course1->id);
|
||||
$coursecontext1 = \context_course::instance($course1->id);
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2017 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +35,7 @@ require_once($CFG->dirroot . '/login/lib.php');
|
||||
* @copyright 2017 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_login_lib_testcase extends advanced_testcase {
|
||||
class login_lib_test extends \advanced_testcase {
|
||||
|
||||
public function test_core_login_process_password_reset_one_time_without_username_protection() {
|
||||
global $CFG;
|
||||
@@ -395,8 +396,8 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
// So we inject our own validation method here and revert it back once we are done. This custom validator method
|
||||
// is identical to the default 'php' validator with the only difference: it has the FILTER_FLAG_EMAIL_UNICODE
|
||||
// set so that it allows to use non-ASCII characters in email addresses.
|
||||
$defaultvalidator = moodle_phpmailer::$validator;
|
||||
moodle_phpmailer::$validator = function($address) {
|
||||
$defaultvalidator = \moodle_phpmailer::$validator;
|
||||
\moodle_phpmailer::$validator = function($address) {
|
||||
return (bool) filter_var($address, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE);
|
||||
};
|
||||
|
||||
@@ -421,7 +422,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$emails = $sink->get_messages();
|
||||
$this->assertCount(1, $emails);
|
||||
$email = reset($emails);
|
||||
$this->assertSame(core_text::strtolower($u2->email), core_text::strtolower($email->to));
|
||||
$this->assertSame(\core_text::strtolower($u2->email), \core_text::strtolower($email->to));
|
||||
$sink->clear();
|
||||
|
||||
// However, emails are accent sensitive - note this is the u1's email with a single character a -> á changed.
|
||||
@@ -444,7 +445,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$sink->clear();
|
||||
|
||||
// Restore the original email address validator.
|
||||
moodle_phpmailer::$validator = $defaultvalidator;
|
||||
\moodle_phpmailer::$validator = $defaultvalidator;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/lib/externallib.php');
|
||||
|
||||
/**
|
||||
* Contains tests for course related notifications.
|
||||
*
|
||||
@@ -21,7 +28,7 @@
|
||||
* @copyright 2021 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_login_notifications_testcase extends \advanced_testcase {
|
||||
class login_notifications_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Load required classes
|
||||
@@ -134,7 +141,7 @@ class core_login_notifications_testcase extends \advanced_testcase {
|
||||
// Mock data for test.
|
||||
$loginuser->lastip = '1.2.3.4.6'; // Different ip that current.
|
||||
$SESSION->isnewsessioncookie = true; // New session cookie.
|
||||
core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
\core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
@complete_user_login($loginuser);
|
||||
|
||||
// Redirect messages to sink and stop buffer output from CLI task.
|
||||
@@ -165,7 +172,7 @@ class core_login_notifications_testcase extends \advanced_testcase {
|
||||
|
||||
$service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
|
||||
$token = external_generate_token_for_current_user($service);
|
||||
core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
\core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
|
||||
// Simulate we are using an new device.
|
||||
$fakedevice = (object) [
|
||||
@@ -214,7 +221,7 @@ class core_login_notifications_testcase extends \advanced_testcase {
|
||||
$USER->lastip = '0.0.0.0';
|
||||
$service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
|
||||
$token = external_generate_token_for_current_user($service);
|
||||
core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
\core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
|
||||
// Simulate we are using an new device.
|
||||
$fakedevice = (object) [
|
||||
@@ -261,7 +268,7 @@ class core_login_notifications_testcase extends \advanced_testcase {
|
||||
$USER->lastip = '1.2.3.4.6'; // New ip.
|
||||
$service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
|
||||
$token = external_generate_token_for_current_user($service);
|
||||
core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
\core_useragent::instance(true, 'MoodleMobile'); // Force fake mobile app user agent.
|
||||
|
||||
external_log_token_request($token);
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace assignsubmission_file;
|
||||
|
||||
use mod_assign_test_generator;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +36,7 @@ require_once($CFG->dirroot . '/mod/assign/tests/generator.php');
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class assignsubmission_file_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
// Use the generator helper.
|
||||
use mod_assign_test_generator;
|
||||
@@ -63,7 +66,7 @@ class assignsubmission_file_locallib_testcase extends advanced_testcase {
|
||||
$plugin = $assign->get_submission_plugin_by_type('file');
|
||||
|
||||
if ($data) {
|
||||
$data += ['contextid' => context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$data += ['contextid' => \context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$fs = get_file_storage();
|
||||
$fs->create_file_from_string((object)$data, 'Content of ' . $data['filename']);
|
||||
}
|
||||
@@ -90,7 +93,7 @@ class assignsubmission_file_locallib_testcase extends advanced_testcase {
|
||||
$plugin = $assign->get_submission_plugin_by_type('file');
|
||||
$fs = get_file_storage();
|
||||
$fs->create_directory(
|
||||
context_user::instance($student->id)->id,
|
||||
\context_user::instance($student->id)->id,
|
||||
'user',
|
||||
'draft',
|
||||
$itemid,
|
||||
@@ -124,7 +127,7 @@ class assignsubmission_file_locallib_testcase extends advanced_testcase {
|
||||
$submission = (object) ['files_filemanager' => $itemid];
|
||||
|
||||
if ($data) {
|
||||
$data += ['contextid' => context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$data += ['contextid' => \context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$fs = get_file_storage();
|
||||
$fs->create_file_from_string((object)$data, 'Content of ' . $data['filename']);
|
||||
}
|
||||
@@ -151,7 +154,7 @@ class assignsubmission_file_locallib_testcase extends advanced_testcase {
|
||||
$plugin = $assign->get_submission_plugin_by_type('file');
|
||||
$fs = get_file_storage();
|
||||
$fs->create_directory(
|
||||
context_user::instance($student->id)->id,
|
||||
\context_user::instance($student->id)->id,
|
||||
'user',
|
||||
'draft',
|
||||
$itemid,
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace assignsubmission_onlinetext;
|
||||
|
||||
use mod_assign_test_generator;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +36,7 @@ require_once($CFG->dirroot . '/mod/assign/tests/generator.php');
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class assignsubmission_onlinetext_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
// Use the generator helper.
|
||||
use mod_assign_test_generator;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_assign;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,8 +31,9 @@ require_once($CFG->dirroot . '/mod/assign/lib.php');
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/assign/tests/generator.php');
|
||||
|
||||
use \core_calendar\local\api as calendar_local_api;
|
||||
use \core_calendar\local\event\container as calendar_event_container;
|
||||
use core_calendar\local\api as calendar_local_api;
|
||||
use core_calendar\local\event\container as calendar_event_container;
|
||||
use mod_assign_test_generator;
|
||||
|
||||
/**
|
||||
* Unit tests for (some of) mod/assign/lib.php.
|
||||
@@ -40,8 +41,7 @@ use \core_calendar\local\event\container as calendar_event_container;
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
class mod_assign_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
// Use the generator helper.
|
||||
use mod_assign_test_generator;
|
||||
@@ -142,7 +142,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
$assign = $this->create_instance($course, ['submissiondrafts' => 1]);
|
||||
$this->add_submission($student, $assign);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
|
||||
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
|
||||
@@ -685,7 +685,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -719,7 +719,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -741,7 +741,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($course, $assign, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'assign';
|
||||
$event->courseid = $course->id;
|
||||
@@ -750,7 +750,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -784,7 +784,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_assign_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_assign_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_assign_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_assign_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_assign_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1296,7 +1296,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
|
||||
$roleid = $this->getDataGenerator()->create_role();
|
||||
$role = $DB->get_record('role', ['id' => $roleid]);
|
||||
@@ -1306,8 +1306,8 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
$mapper = calendar_event_container::get_event_mapper();
|
||||
$now = time();
|
||||
$duedate = (new DateTime())->setTimestamp($now);
|
||||
$newduedate = (new DateTime())->setTimestamp($now)->modify('+1 day');
|
||||
$duedate = (new \DateTime())->setTimestamp($now);
|
||||
$newduedate = (new \DateTime())->setTimestamp($now)->modify('+1 day');
|
||||
$assign = $this->create_instance($course, [
|
||||
'course' => $course->id,
|
||||
'duedate' => $duedate->getTimestamp(),
|
||||
@@ -1352,7 +1352,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
$roleid = $DB->get_field('role', 'id', ['shortname' => 'teacher']);
|
||||
|
||||
@@ -1360,8 +1360,8 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
$mapper = calendar_event_container::get_event_mapper();
|
||||
$now = time();
|
||||
$duedate = (new DateTime())->setTimestamp($now);
|
||||
$newduedate = (new DateTime())->setTimestamp($now)->modify('+1 day');
|
||||
$duedate = (new \DateTime())->setTimestamp($now);
|
||||
$newduedate = (new \DateTime())->setTimestamp($now)->modify('+1 day');
|
||||
$assign = $this->create_instance($course, [
|
||||
'course' => $course->id,
|
||||
'duedate' => $duedate->getTimestamp(),
|
||||
@@ -1411,7 +1411,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
+106
-102
@@ -22,7 +22,11 @@
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_assign;
|
||||
|
||||
use mod_assign_grade_form;
|
||||
use mod_assign_test_generator;
|
||||
use mod_assign_testable_assign;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -37,7 +41,7 @@ require_once($CFG->dirroot . '/mod/assign/tests/generator.php');
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
// Use the generator helper.
|
||||
use mod_assign_test_generator;
|
||||
@@ -49,7 +53,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
|
||||
$assign = $this->create_instance($course);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
$assign->register_return_link('RETURNACTION', ['param' => 1]);
|
||||
$this->assertEquals('RETURNACTION', $assign->get_return_action());
|
||||
@@ -63,7 +67,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$this->setUser($teacher);
|
||||
$assign = $this->create_instance($course);
|
||||
$installedplugins = array_keys(core_component::get_plugin_list('assignfeedback'));
|
||||
$installedplugins = array_keys(\core_component::get_plugin_list('assignfeedback'));
|
||||
|
||||
foreach ($assign->get_feedback_plugins() as $plugin) {
|
||||
$this->assertContains($plugin->get_type(), $installedplugins, 'Feedback plugin not in list of installed plugins');
|
||||
@@ -77,7 +81,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$this->setUser($teacher);
|
||||
$assign = $this->create_instance($course);
|
||||
$installedplugins = array_keys(core_component::get_plugin_list('assignsubmission'));
|
||||
$installedplugins = array_keys(\core_component::get_plugin_list('assignsubmission'));
|
||||
|
||||
foreach ($assign->get_submission_plugins() as $plugin) {
|
||||
$this->assertContains($plugin->get_type(), $installedplugins, 'Submission plugin not in list of installed plugins');
|
||||
@@ -95,7 +99,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(true, $assign->is_blind_marking());
|
||||
|
||||
// Test cannot see student names.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertEquals(true, strpos($output, get_string('hiddenuser', 'assign')));
|
||||
|
||||
@@ -128,7 +132,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$teacher->ignoresesskey = false;
|
||||
|
||||
// Test student names are visible.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertEquals(false, strpos($output, get_string('hiddenuser', 'assign')));
|
||||
|
||||
@@ -209,13 +213,13 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'grade' => GRADE_TYPE_NONE
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Render the table with the requires grading filter.
|
||||
$gradingtable = new assign_grading_table($assign, 1, ASSIGN_FILTER_REQUIRE_GRADING, 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, ASSIGN_FILTER_REQUIRE_GRADING, 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
|
||||
// Test that the filter function does not throw errors for assignments with no grade.
|
||||
@@ -241,13 +245,13 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
'duedate' => time() - (4 * DAYSECS),
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Check that the assignment is late.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
$this->assertStringContainsString(get_string('overdue', 'assign', format_time((4 * DAYSECS))), $output);
|
||||
@@ -255,7 +259,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Grant an extension.
|
||||
$extendedtime = $time + (2 * DAYSECS);
|
||||
$assign->testable_save_user_extension($student->id, $extendedtime);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($extendedtime)), $output);
|
||||
@@ -265,7 +269,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $student->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = [
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -276,7 +280,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Verify output.
|
||||
$this->setUser($teacher);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_submitted', 'assign'), $output);
|
||||
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($extendedtime)), $output);
|
||||
@@ -300,13 +304,13 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
'duedate' => time() - (4 * DAYSECS),
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Check that the assignment is late.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
$difftime = time() - $time;
|
||||
@@ -314,7 +318,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Grant an extension that is in the past.
|
||||
$assign->testable_save_user_extension($student->id, $time - (2 * DAYSECS));
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($time - (2 * DAYSECS))), $output);
|
||||
@@ -326,7 +330,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $student->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = [
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -338,7 +342,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Verify output.
|
||||
$this->setUser($teacher);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_submitted', 'assign'), $output);
|
||||
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($time - (2 * DAYSECS))), $output);
|
||||
@@ -363,13 +367,13 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
'duedate' => $time - (4 * DAYSECS),
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Check that the assignment is late.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
$difftime = time() - $time;
|
||||
@@ -384,14 +388,14 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Verify output.
|
||||
$this->setUser($teacher);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$difftime = $submittedtime - $time;
|
||||
$this->assertStringContainsString(get_string('overdue', 'assign', format_time((4 * DAYSECS) + $difftime)), $output);
|
||||
|
||||
$document = new DOMDocument();
|
||||
$document = new \DOMDocument();
|
||||
@$document->loadHTML($output);
|
||||
$xpath = new DOMXPath($document);
|
||||
$xpath = new \DOMXPath($document);
|
||||
$this->assertEmpty($xpath->evaluate('string(//td[@id="mod_assign_grading-' . $assign->get_context()->id. '_r0_c8"])'));
|
||||
}
|
||||
|
||||
@@ -435,14 +439,14 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
'requireallteammemberssubmit' => 0,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Add a submission.
|
||||
$this->setUser($student);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = [
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -457,11 +461,11 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Check output.
|
||||
$this->setUser($teacher);
|
||||
$gradingtable = new assign_grading_table($assign, 4, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 4, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$document = new DOMDocument();
|
||||
$document = new \DOMDocument();
|
||||
@$document->loadHTML($output);
|
||||
$xpath = new DOMXPath($document);
|
||||
$xpath = new \DOMXPath($document);
|
||||
|
||||
// The XPath expression is based on the unique ID of the table.
|
||||
$xpathuniqueidroot = 'mod_assign_grading-' . $assign->get_context()->id;
|
||||
@@ -538,7 +542,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Submit the submission.
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $student->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -561,7 +565,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $student->id, 0);
|
||||
|
||||
@@ -587,7 +591,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $student->id, 0);
|
||||
|
||||
@@ -622,7 +626,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Simulate a submission.
|
||||
$this->setUser($student);
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -632,7 +636,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertEquals(true, $assign->has_submissions_or_grades());
|
||||
// Now try and reset.
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->reset_assign_submissions = 1;
|
||||
$data->reset_gradebook_grades = 1;
|
||||
$data->reset_assign_user_overrides = 1;
|
||||
@@ -707,7 +711,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
|
||||
$this->setUser($teacher);
|
||||
$userctx = context_user::instance($teacher->id)->id;
|
||||
$userctx = \context_user::instance($teacher->id)->id;
|
||||
|
||||
// Hack to pretend that there was an editor involved. We need both $_POST and $_REQUEST, and a sesskey.
|
||||
$draftid = file_get_unused_draft_itemid();
|
||||
@@ -721,7 +725,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$fakearealink2 = file_rewrite_pluginfile_urls('<a href="@@PLUGINFILE@@/pic.gif">new</a>', 'draftfile.php', $userctx,
|
||||
'user', 'draft', $draftid);
|
||||
|
||||
// Create a new assignment with links to a draft area.
|
||||
// Create a new \assignment with links to a draft area.
|
||||
$now = time();
|
||||
$assign = $this->create_instance($course, [
|
||||
'duedate' => $now,
|
||||
@@ -768,7 +772,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// and we want to test that this works from cron.
|
||||
$DB->set_field('assign', 'allowsubmissionsfromdate', $now - 60, array('id' => $assign->get_instance()->id));
|
||||
// Run cron to update the event in the calendar.
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$event = $DB->get_record('event', $params);
|
||||
|
||||
$this->assertStringContainsString('Some text', $event->description);
|
||||
@@ -808,7 +812,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$assign = $this->create_instance($course, ['submissiondrafts' => 1]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Test you cannot see the submit button for an offline assignment regardless.
|
||||
$this->setUser($student);
|
||||
@@ -830,7 +834,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Test you cannot see the submit button for an online text assignment with no submission.
|
||||
$this->setUser($student);
|
||||
@@ -852,7 +856,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Add a draft.
|
||||
$this->add_submission($student, $assign);
|
||||
@@ -887,12 +891,12 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$this->setUser($student);
|
||||
$submission = new stdClass();
|
||||
$submission = new \stdClass();
|
||||
|
||||
if ($data['file'] && isset($data['file']['filename'])) {
|
||||
$itemid = file_get_unused_draft_itemid();
|
||||
$submission->files_filemanager = $itemid;
|
||||
$data['file'] += ['contextid' => context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$data['file'] += ['contextid' => \context_user::instance($student->id)->id, 'itemid' => $itemid];
|
||||
$fs = get_file_storage();
|
||||
$fs->create_file_from_string((object)$data['file'], 'Content of ' . $data['file']['filename']);
|
||||
}
|
||||
@@ -1072,7 +1076,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$assign = $this->create_instance($course);
|
||||
$teacher = self::getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
$student = self::getDataGenerator()->create_and_enrol($course, 'student');
|
||||
@@ -1093,7 +1097,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$assign = $this->create_instance($course);
|
||||
$teacher = self::getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
$student = self::getDataGenerator()->create_and_enrol($course, 'student');
|
||||
@@ -1128,7 +1132,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$this->mark_submission($teacher, $assign, $student, 50.0);
|
||||
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $student->id, 0);
|
||||
|
||||
@@ -1461,7 +1465,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $this->extrastudents[0]->id, 0);
|
||||
|
||||
@@ -1470,7 +1474,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$submission = $assign->get_group_submission($this->extrastudents[1]->id, $groupid, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $this->extrastudents[1]->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -1483,7 +1487,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$submission = $assign->get_group_submission($this->extrastudents[2]->id, $groupid, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $this->extrastudents[2]->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -1496,7 +1500,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$submission = $assign->get_group_submission($this->extrastudents[3]->id, $groupid, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $this->extrastudents[3]->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = array(
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
@@ -1506,7 +1510,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $this->extrastudents[3]->id, 0);
|
||||
$assign->testable_apply_grade_to_user($data, $this->extrasuspendedstudents[0]->id, 0);
|
||||
@@ -1559,7 +1563,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
@@ -1578,7 +1582,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
||||
cron_setup_user();
|
||||
$sink = $this->redirectMessages();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
$this->assertEquals(1, count($messages));
|
||||
@@ -1589,7 +1593,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($assign->get_course_module()->id, $customdata->cmid);
|
||||
$this->assertEquals($assign->get_instance()->id, $customdata->instance);
|
||||
$this->assertEquals('feedbackavailable', $customdata->messagetype);
|
||||
$userpicture = new user_picture($teacher);
|
||||
$userpicture = new \user_picture($teacher);
|
||||
$userpicture->size = 1; // Use f1 size.
|
||||
$this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationiconurl);
|
||||
$this->assertEquals(0, $customdata->uniqueidforuser); // Not used in this case.
|
||||
@@ -1601,7 +1605,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
@@ -1621,7 +1625,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
cron_setup_user();
|
||||
$sink = $this->redirectMessages();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
$this->assertEquals(0, count($messages));
|
||||
@@ -1632,7 +1636,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
@@ -1650,7 +1654,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
// Regrade.
|
||||
$this->mark_submission($teacher, $assign, $student, 50.0);
|
||||
@@ -1658,7 +1662,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
||||
cron_setup_user();
|
||||
$sink = $this->redirectMessages();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
$this->assertEquals(1, count($messages));
|
||||
@@ -1674,7 +1678,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
@@ -1698,7 +1702,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
cron_setup_user();
|
||||
$sink = $this->redirectMessages();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
$this->assertEquals(0, count($messages));
|
||||
@@ -1713,7 +1717,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
cron_setup_user();
|
||||
$sink = $this->redirectMessages();
|
||||
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
$this->assertEquals(1, count($messages));
|
||||
@@ -1726,7 +1730,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
@@ -1743,14 +1747,14 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->add_submission($student, $assign);
|
||||
$this->submit_for_grading($student, $assign);
|
||||
$this->mark_submission($teacher, $assign, $student);
|
||||
phpunit_util::stop_message_redirection();
|
||||
\phpunit_util::stop_message_redirection();
|
||||
|
||||
// Now run cron and see that one message was sent.
|
||||
cron_setup_user();
|
||||
$this->preventResetByRollback();
|
||||
$sink = $this->redirectEvents();
|
||||
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
@@ -1983,7 +1987,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Now verify group assignments.
|
||||
$this->setUser($teacher);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Add a submission.
|
||||
$this->add_submission($student, $assign);
|
||||
@@ -2038,7 +2042,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'requireallteammemberssubmit' => 0,
|
||||
'duedate' => $time - (2 * DAYSECS),
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Add a submission.
|
||||
$this->add_submission($student, $assign);
|
||||
@@ -2202,7 +2206,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
|
||||
$capability = 'mod/assign:receivegradernotifications';
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$role = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
|
||||
$this->setUser($teacher);
|
||||
@@ -2261,7 +2265,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Change nonediting teachers role to not receive grader notifications.
|
||||
$capability = 'mod/assign:receivegradernotifications';
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
$role = $DB->get_record('role', ['shortname' => 'teacher']);
|
||||
assign_capability($capability, CAP_PROHIBIT, $role->id, $coursecontext);
|
||||
|
||||
@@ -2364,7 +2368,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
$this->setUser($teacher);
|
||||
$assign = $this->create_instance($course);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// No feedback should be available because this student has not been graded.
|
||||
$this->setUser($student);
|
||||
@@ -2384,7 +2388,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Now hide the grade in gradebook.
|
||||
$this->setUser($teacher);
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
$gradeitem = new grade_item(array(
|
||||
$gradeitem = new \grade_item(array(
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => 'assign',
|
||||
'iteminstance' => $assign->get_instance()->id,
|
||||
@@ -2430,7 +2434,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$assign = $this->create_instance($course, [
|
||||
'assignfeedback_comments_enabled' => 1
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// No feedback should be available because this student has not been graded.
|
||||
$this->setUser($student);
|
||||
@@ -2473,7 +2477,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Now hide the grade in gradebook.
|
||||
$this->setUser($teacher);
|
||||
$gradeitem = new grade_item(array(
|
||||
$gradeitem = new \grade_item(array(
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => 'assign',
|
||||
'iteminstance' => $assign->get_instance()->id,
|
||||
@@ -2505,7 +2509,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Student should be able to see an add submission button.
|
||||
$this->setUser($student);
|
||||
@@ -2553,7 +2557,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($teacher);
|
||||
// Check that the grading table loads correctly and contains this user.
|
||||
// This is also testing that we do not get duplicate rows in the grading table.
|
||||
$gradingtable = new assign_grading_table($assign, 100, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 100, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertEquals(true, strpos($output, $student->lastname));
|
||||
|
||||
@@ -2603,7 +2607,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Set grade to pass to 80.
|
||||
$gradeitem = $assign->get_grade_item();
|
||||
@@ -2677,7 +2681,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Set grade to pass to 80.
|
||||
$gradeitem = $assign->get_grade_item();
|
||||
@@ -2720,7 +2724,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Set grade to pass to 0, so that no attempts should reopen.
|
||||
$gradeitem = $assign->get_grade_item();
|
||||
@@ -2764,7 +2768,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'markingworkflow' => 1,
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Mark the submission and set to notmarked.
|
||||
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
||||
@@ -2868,7 +2872,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'markingallocation' => 1
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Allocate marker to submission.
|
||||
$this->mark_submission($teacher, $assign, $student, null, [
|
||||
@@ -2882,7 +2886,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->assertTrue(isset($users[$student->id]));
|
||||
|
||||
$cm = get_coursemodule_from_instance('assign', $assign->get_instance()->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$assign = new mod_assign_testable_assign($context, $cm, $course);
|
||||
|
||||
// Check that other teachers can't view this submission.
|
||||
@@ -2907,7 +2911,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'submissiondrafts' => 1,
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Add a submission but do not submit.
|
||||
$this->add_submission($student, $assign, 'Student submission text');
|
||||
@@ -2946,7 +2950,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
role_assign($roleid, $teacher->id, $assign->get_context()->id);
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Add a submission but do not submit.
|
||||
$this->add_submission($student, $assign, 'Student submission text');
|
||||
@@ -3012,7 +3016,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Student should be able to see an add submission button.
|
||||
$this->setUser($student);
|
||||
@@ -3141,7 +3145,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
$this->setUser($teacher);
|
||||
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
require_once($CFG->dirroot . '/mod/assign/gradeform.php');
|
||||
$pagination = [
|
||||
'userid' => $student->id,
|
||||
@@ -3154,7 +3158,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$mform = new mod_assign_grade_form(null, [$assign, $data, $pagination]);
|
||||
|
||||
// We need to get the URL these will be transformed to.
|
||||
$context = context_user::instance($USER->id);
|
||||
$context = \context_user::instance($USER->id);
|
||||
$itemid = $data->assignfeedbackcomments_editor['itemid'];
|
||||
$url = $CFG->wwwroot . '/draftfile.php/' . $context->id . '/user/draft/' . $itemid;
|
||||
|
||||
@@ -3387,7 +3391,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
'groupmode' => SEPARATEGROUPS,
|
||||
]);
|
||||
|
||||
// Add the capability to the new assignment for student 1.
|
||||
// Add the capability to the new \assignment for student 1.
|
||||
$roleid = create_role('Dummy role', 'dummyrole', 'dummy role description');
|
||||
assign_capability('mod/assign:editothersubmission', CAP_ALLOW, $roleid, $assign->get_context()->id);
|
||||
role_assign($roleid, $student1->id, $assign->get_context()->id);
|
||||
@@ -3426,14 +3430,14 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
// Test student names are hidden to teacher.
|
||||
$this->setUser($teacher);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertEquals(true, strpos($output, get_string('hiddenuser', 'assign'))); // "Participant" is somewhere on the page.
|
||||
$this->assertEquals(false, strpos($output, fullname($student))); // Students full name doesn't appear.
|
||||
|
||||
// Test student names are visible to manager.
|
||||
$this->setUser($manager);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertEquals(true, strpos($output, get_string('hiddenuser', 'assign')));
|
||||
$this->assertEquals(true, strpos($output, fullname($student)));
|
||||
@@ -3567,7 +3571,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
// Test that all the submission and feedback plugins are returning the expected file aras.
|
||||
$usingfilearea = 0;
|
||||
$coreplugins = core_plugin_manager::standard_plugins_list('assignsubmission');
|
||||
$coreplugins = \core_plugin_manager::standard_plugins_list('assignsubmission');
|
||||
foreach ($assign->get_submission_plugins() as $plugin) {
|
||||
$type = $plugin->get_type();
|
||||
if (!in_array($type, $coreplugins)) {
|
||||
@@ -3588,7 +3592,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->assertEquals(2, $usingfilearea);
|
||||
|
||||
$usingfilearea = 0;
|
||||
$coreplugins = core_plugin_manager::standard_plugins_list('assignfeedback');
|
||||
$coreplugins = \core_plugin_manager::standard_plugins_list('assignfeedback');
|
||||
foreach ($assign->get_feedback_plugins() as $plugin) {
|
||||
$type = $plugin->get_type();
|
||||
if (!in_array($type, $coreplugins)) {
|
||||
@@ -3812,7 +3816,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->add_submission($student, $assign);
|
||||
|
||||
// Check that completion is not met yet.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm, false, $student->id);
|
||||
$this->assertEquals(0, $completiondata->completionstate);
|
||||
|
||||
@@ -3854,7 +3858,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->add_submission($student, $assign);
|
||||
$this->submit_for_grading($student, $assign, ['groupid' => $group1->id]);
|
||||
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
|
||||
// Check that completion is not met yet.
|
||||
$completiondata = $completion->get_data($cm, false, $student->id);
|
||||
@@ -3906,7 +3910,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
$this->add_submission($student, $assign);
|
||||
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
|
||||
// Completion should now be met.
|
||||
$completiondata = $completion->get_data($cm, false, $student->id);
|
||||
@@ -3989,18 +3993,18 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
// Check that the gradebook was updated with the assign grade. So we can guarentee test results later on.
|
||||
$expectedgrade = $grade == -1 ? null : $grade; // Assign sends null to the gradebook for -1 grades.
|
||||
$gradegrade = grade_grade::fetch(array('userid' => $student->id, 'itemid' => $assign->get_grade_item()->id));
|
||||
$gradegrade = \grade_grade::fetch(array('userid' => $student->id, 'itemid' => $assign->get_grade_item()->id));
|
||||
$this->assertEquals(-1, $gradegrade->usermodified);
|
||||
$this->assertEquals($expectedgrade, $gradegrade->rawgrade);
|
||||
|
||||
// Call fix_null_grades().
|
||||
$method = new ReflectionMethod(assign::class, 'fix_null_grades');
|
||||
$method = new \ReflectionMethod(\assign::class, 'fix_null_grades');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($assign);
|
||||
|
||||
$this->assertSame(true, $result);
|
||||
|
||||
$gradegrade = grade_grade::fetch(array('userid' => $student->id, 'itemid' => $assign->get_grade_item()->id));
|
||||
$gradegrade = \grade_grade::fetch(array('userid' => $student->id, 'itemid' => $assign->get_grade_item()->id));
|
||||
|
||||
$this->assertEquals(-1, $gradegrade->usermodified);
|
||||
$this->assertEquals($gradebookvalue, $gradegrade->finalgrade);
|
||||
@@ -4028,12 +4032,12 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $student->id, 0);
|
||||
|
||||
// Set grade override.
|
||||
$gradegrade = grade_grade::fetch([
|
||||
$gradegrade = \grade_grade::fetch([
|
||||
'userid' => $student->id,
|
||||
'itemid' => $assign->get_grade_item()->id,
|
||||
]);
|
||||
@@ -4045,14 +4049,14 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->setUser($student);
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
||||
|
||||
// Set override grade grade, and check that grade submission has been overridden.
|
||||
$gradegrade->set_overridden(true);
|
||||
$this->assertEquals(true, $gradegrade->is_overridden());
|
||||
|
||||
// Check that submissionslocked message 'This assignment is not accepting submissions' does not appear for student.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertStringContainsString(get_string('submissionstatus_', 'assign'), $output);
|
||||
|
||||
@@ -4259,7 +4263,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$DB->delete_records('event', $params);
|
||||
|
||||
// Run cron.
|
||||
assign::cron();
|
||||
\assign::cron();
|
||||
|
||||
// Assert that calendar hasn't been updated for the first assignment as it's supposed to be
|
||||
// updated as part of previous cron runs (allowsubmissionsfromdate is less than lastruntime).
|
||||
@@ -4292,7 +4296,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$assign = $this->create_instance($course, [
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', [
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
]));
|
||||
@@ -4309,7 +4313,7 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$submission = $assign->get_user_submission($student->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $student->id, true, false);
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->onlinetext_editor = [
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
|
||||
+16
-16
@@ -22,7 +22,7 @@
|
||||
* @copyright 2015 Juan Leyva <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_book;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/mod/book/lib.php');
|
||||
* @copyright 2015 Juan Leyva <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_book_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
@@ -64,7 +64,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$bookgenerator = $this->getDataGenerator()->get_plugin_generator('mod_book');
|
||||
$chapter1 = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 1,
|
||||
'tags' => array('Cats', 'Dogs')));
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
$chapter2 = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 2));
|
||||
$subchapter = $bookgenerator->create_chapter(array('bookid' => $book->id, "pagenum" => 3, "subchapter" => 1));
|
||||
@@ -89,8 +89,8 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals('Chapter 3', $contents[3]['content']);
|
||||
|
||||
// Now, test the function via the external API.
|
||||
$contents = core_course_external::get_course_contents($course->id, array());
|
||||
$contents = external_api::clean_returnvalue(core_course_external::get_course_contents_returns(), $contents);
|
||||
$contents = \core_course_external::get_course_contents($course->id, array());
|
||||
$contents = \external_api::clean_returnvalue(\core_course_external::get_course_contents_returns(), $contents);
|
||||
|
||||
$this->assertCount(4, $contents[0]['modules'][0]['contents']);
|
||||
|
||||
@@ -144,8 +144,8 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals('Chapter 4', $contents[4]['content']);
|
||||
|
||||
// Now, test the function via the external API.
|
||||
$contents = core_course_external::get_course_contents($course->id, array());
|
||||
$contents = external_api::clean_returnvalue(core_course_external::get_course_contents_returns(), $contents);
|
||||
$contents = \core_course_external::get_course_contents($course->id, array());
|
||||
$contents = \external_api::clean_returnvalue(\core_course_external::get_course_contents_returns(), $contents);
|
||||
|
||||
$this->assertCount(5, $contents[0]['modules'][0]['contents']);
|
||||
|
||||
@@ -206,7 +206,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$bookgenerator = $this->getDataGenerator()->get_plugin_generator('mod_book');
|
||||
$chapter = $bookgenerator->create_chapter(array('bookid' => $book->id));
|
||||
|
||||
$context = context_module::instance($book->cmid);
|
||||
$context = \context_module::instance($book->cmid);
|
||||
$cm = get_coursemodule_from_instance('book', $book->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -235,7 +235,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$this->assertCount(4, $events);
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -397,7 +397,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -419,7 +419,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'book';
|
||||
$event->courseid = $courseid;
|
||||
@@ -428,7 +428,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
public function test_mod_book_get_tagged_chapters() {
|
||||
@@ -456,7 +456,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$chapter23 = $bookgenerator->create_content($book2, array('tags' => array('mice', 'Cats')));
|
||||
$chapter31 = $bookgenerator->create_content($book3, array('tags' => array('mice', 'Cats')));
|
||||
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
@@ -494,7 +494,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course1->id, $studentrole->id, 'manual');
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course2->id, $studentrole->id, 'manual');
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can not see chapters in course 3 because he is not enrolled.
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
@@ -504,7 +504,7 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter31->title.'/', $res->content);
|
||||
|
||||
// User can search book chapters inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$coursecontext = \context_course::instance($course1->id);
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$chapter = */0);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter11->title.'/', $res->content);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace booktool_importhtml;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
@@ -36,7 +37,7 @@ require_once($CFG->dirroot.'/mod/book/tool/importhtml/locallib.php');
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class booktool_importhtml_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
@@ -45,9 +46,9 @@ class booktool_importhtml_locallib_testcase extends advanced_testcase {
|
||||
public function test_import_chapters_events() {
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
|
||||
$context = context_module::instance($book->cmid);
|
||||
$context = \context_module::instance($book->cmid);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->contextid = $context->id;
|
||||
$record->component = 'phpunit';
|
||||
$record->filearea = 'test';
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_chat;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_chat_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
@@ -652,7 +653,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -685,7 +686,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -707,7 +708,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'chat';
|
||||
$event->courseid = $courseid;
|
||||
@@ -716,7 +717,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,7 +726,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_choice;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -40,7 +41,7 @@ require_once($CFG->dirroot . '/mod/choice/lib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
class lib_test extends \externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test choice_view
|
||||
@@ -55,7 +56,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
// Setup test data.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$choice = $this->getDataGenerator()->create_module('choice', array('course' => $course->id));
|
||||
$context = context_module::instance($choice->cmid);
|
||||
$context = \context_module::instance($choice->cmid);
|
||||
$cm = get_coursemodule_from_instance('choice', $choice->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -89,7 +90,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
// Setup test data.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$choice = $this->getDataGenerator()->create_module('choice', array('course' => $course->id));
|
||||
$context = context_module::instance($choice->cmid);
|
||||
$context = \context_module::instance($choice->cmid);
|
||||
$cm = get_coursemodule_from_instance('choice', $choice->id);
|
||||
|
||||
// Default values are false, user cannot view results.
|
||||
@@ -156,7 +157,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
$optionids2 = array_keys($choicewithoptions2->option);
|
||||
|
||||
// Make sure we cannot submit options from a different choice instance.
|
||||
$this->expectException(moodle_exception::class);
|
||||
$this->expectException(\moodle_exception::class);
|
||||
choice_user_submit_response($optionids2[0], $choice1, $USER->id, $course, $cm);
|
||||
}
|
||||
|
||||
@@ -730,7 +731,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -764,7 +765,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -787,7 +788,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype, $timestart = null) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'choice';
|
||||
$event->courseid = $courseid;
|
||||
@@ -801,7 +802,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
$event->timestart = time();
|
||||
}
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -825,13 +826,13 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionsubmit' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('choice', $choice1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('choice', $choice2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('choice', $choice1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('choice', $choice2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => ['completionsubmit' => 1]];
|
||||
$moddefaults->completion = 2;
|
||||
|
||||
@@ -839,7 +840,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(mod_choice_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_choice_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_choice_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_choice_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_choice_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1338,7 +1339,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
+63
-62
@@ -22,6 +22,7 @@
|
||||
* @copyright 2013 Adrian Greeve
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_data;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,7 +36,7 @@ require_once($CFG->dirroot . '/mod/data/lib.php');
|
||||
* @copyright 2013 Adrian Greeve
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_data_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var moodle_database
|
||||
@@ -66,7 +67,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$CFG->enablecompletion = 1;
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->name = "Mod data completion test";
|
||||
$record->intro = "Some intro of some sort";
|
||||
@@ -77,13 +78,13 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$module = $this->getDataGenerator()->create_module('data', $record, array('completion' => 2, 'completionentries' => 1));
|
||||
|
||||
$cm = get_coursemodule_from_instance('data', $module->id, $course->id);
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm, true, 0);
|
||||
/* Confirm it is not complete as there are no entries */
|
||||
$this->assertNotEquals(1, $completiondata->completionstate);
|
||||
|
||||
$field = data_get_field_new('text', $module);
|
||||
$fielddetail = new stdClass();
|
||||
$fielddetail = new \stdClass();
|
||||
$fielddetail->d = $module->id;
|
||||
$fielddetail->mode = 'add';
|
||||
$fielddetail->type = 'text';
|
||||
@@ -102,7 +103,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$contentid = $DB->insert_record('data_content', $datacontent);
|
||||
|
||||
$cm = get_coursemodule_from_instance('data', $module->id, $course->id);
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
/* Confirm it is complete because it has 1 entry */
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
@@ -116,7 +117,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Create a record for deleting.
|
||||
$this->setAdminUser();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->name = "Mod data delete test";
|
||||
$record->intro = "Some intro of some sort";
|
||||
@@ -125,7 +126,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
|
||||
$field = data_get_field_new('text', $module);
|
||||
|
||||
$fielddetail = new stdClass();
|
||||
$fielddetail = new \stdClass();
|
||||
$fielddetail->d = $module->id;
|
||||
$fielddetail->mode = 'add';
|
||||
$fielddetail->type = 'text';
|
||||
@@ -188,7 +189,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Create a record for deleting.
|
||||
$this->setAdminUser();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->name = "Mod data delete test";
|
||||
$record->intro = "Some intro of some sort";
|
||||
@@ -197,7 +198,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$module = $this->getDataGenerator()->create_module('data', $record);
|
||||
$field = data_get_field_new('text', $module);
|
||||
|
||||
$fielddetail = new stdClass();
|
||||
$fielddetail = new \stdClass();
|
||||
$fielddetail->name = 'Name';
|
||||
$fielddetail->description = 'Some name';
|
||||
|
||||
@@ -213,8 +214,8 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$contentid = $DB->insert_record('data_content', $datacontent);
|
||||
$cm = get_coursemodule_from_instance('data', $module->id, $course->id);
|
||||
|
||||
$context = context_module::instance($module->cmid);
|
||||
$cmt = new stdClass();
|
||||
$context = \context_module::instance($module->cmid);
|
||||
$cmt = new \stdClass();
|
||||
$cmt->context = $context;
|
||||
$cmt->course = $course;
|
||||
$cmt->cm = $cm;
|
||||
@@ -222,7 +223,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$cmt->itemid = $recordid;
|
||||
$cmt->showcount = true;
|
||||
$cmt->component = 'mod_data';
|
||||
$comment = new comment($cmt);
|
||||
$comment = new \comment($cmt);
|
||||
|
||||
// Triggering and capturing the event.
|
||||
$sink = $this->redirectEvents();
|
||||
@@ -234,7 +235,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_data\event\comment_created', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$url = new moodle_url('/mod/data/view.php', array('id' => $cm->id));
|
||||
$url = new \moodle_url('/mod/data/view.php', array('id' => $cm->id));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
@@ -251,7 +252,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Create a record for deleting.
|
||||
$this->setAdminUser();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->name = "Mod data delete test";
|
||||
$record->intro = "Some intro of some sort";
|
||||
@@ -260,7 +261,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$module = $this->getDataGenerator()->create_module('data', $record);
|
||||
$field = data_get_field_new('text', $module);
|
||||
|
||||
$fielddetail = new stdClass();
|
||||
$fielddetail = new \stdClass();
|
||||
$fielddetail->name = 'Name';
|
||||
$fielddetail->description = 'Some name';
|
||||
|
||||
@@ -276,8 +277,8 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$contentid = $DB->insert_record('data_content', $datacontent);
|
||||
$cm = get_coursemodule_from_instance('data', $module->id, $course->id);
|
||||
|
||||
$context = context_module::instance($module->cmid);
|
||||
$cmt = new stdClass();
|
||||
$context = \context_module::instance($module->cmid);
|
||||
$cmt = new \stdClass();
|
||||
$cmt->context = $context;
|
||||
$cmt->course = $course;
|
||||
$cmt->cm = $cm;
|
||||
@@ -285,7 +286,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$cmt->itemid = $recordid;
|
||||
$cmt->showcount = true;
|
||||
$cmt->component = 'mod_data';
|
||||
$comment = new comment($cmt);
|
||||
$comment = new \comment($cmt);
|
||||
$newcomment = $comment->add('New comment 1');
|
||||
|
||||
// Triggering and capturing the event.
|
||||
@@ -298,7 +299,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Checking that the event contains the expected values.
|
||||
$this->assertInstanceOf('\mod_data\event\comment_deleted', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
$url = new moodle_url('/mod/data/view.php', array('id' => $module->cmid));
|
||||
$url = new \moodle_url('/mod/data/view.php', array('id' => $module->cmid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
@@ -317,7 +318,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
@@ -349,7 +350,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
assign_capability('mod/data:manageentries', CAP_PROHIBIT, $roleid, $context);
|
||||
|
||||
// Causes readonly mode to be enabled.
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$now = time();
|
||||
// Add a small margin around the periods to prevent errors with slow tests.
|
||||
$data->timeviewfrom = $now - 1;
|
||||
@@ -373,7 +374,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Causes readonly mode to be disabled.
|
||||
$now = time();
|
||||
$data->timeviewfrom = $now + 100;
|
||||
@@ -404,7 +405,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Causes readonly mode to be disabled.
|
||||
$now = time();
|
||||
$data->timeviewfrom = $now + 100;
|
||||
@@ -436,7 +437,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Causes readonly mode to be disabled.
|
||||
$now = time();
|
||||
$data->timeviewfrom = $now + 100;
|
||||
@@ -470,7 +471,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Causes readonly mode to be disabled.
|
||||
$now = time();
|
||||
$data->timeviewfrom = $now + 100;
|
||||
@@ -506,7 +507,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$roleid = $testdata['roleid'];
|
||||
$context = $testdata['context'];
|
||||
$record = $testdata['record'];
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Causes readonly mode to be disabled.
|
||||
$now = time();
|
||||
$data->timeviewfrom = $now + 100;
|
||||
@@ -543,7 +544,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$roleid = $this->getDataGenerator()->create_role();
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->name = "test name";
|
||||
$record->intro = "test intro";
|
||||
$record->comments = 1;
|
||||
@@ -552,7 +553,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
|
||||
$module = $this->getDataGenerator()->create_module('data', $record);
|
||||
$cm = get_coursemodule_from_instance('data', $module->id, $course->id);
|
||||
$context = context_module::instance($module->cmid);
|
||||
$context = \context_module::instance($module->cmid);
|
||||
|
||||
$this->getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -578,13 +579,13 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Setup test data.
|
||||
$course = new stdClass();
|
||||
$course = new \stdClass();
|
||||
$course->groupmode = SEPARATEGROUPS;
|
||||
$course->groupmodeforce = true;
|
||||
$course = $this->getDataGenerator()->create_course($course);
|
||||
$data = $this->getDataGenerator()->create_module('data', array('course' => $course->id));
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
// Create users.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
@@ -609,7 +610,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
// Add data.
|
||||
$field = data_get_field_new('text', $data);
|
||||
|
||||
$fielddetail = new stdClass();
|
||||
$fielddetail = new \stdClass();
|
||||
$fielddetail->name = 'Name';
|
||||
$fielddetail->description = 'Some name';
|
||||
|
||||
@@ -949,7 +950,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$data = $this->getDataGenerator()->create_module('data', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($data->cmid);
|
||||
$context = \context_module::instance($data->cmid);
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -971,7 +972,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -984,7 +985,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$datagenerator = $this->getDataGenerator()->get_plugin_generator('mod_data');
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
|
||||
$fieldrecord = new StdClass();
|
||||
$fieldrecord = new \stdClass();
|
||||
$fieldrecord->name = 'field-1';
|
||||
$fieldrecord->type = 'text';
|
||||
|
||||
@@ -996,7 +997,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$datagenerator->create_entry($data1, [$field1->field->id => 'value13'], 0, ['Cats']);
|
||||
$datagenerator->create_entry($data1, [$field1->field->id => 'value14'], 0);
|
||||
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1017,7 +1018,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
|
||||
$fieldrecord = new StdClass();
|
||||
$fieldrecord = new \stdClass();
|
||||
$fieldrecord->name = 'field-1';
|
||||
$fieldrecord->type = 'text';
|
||||
|
||||
@@ -1028,7 +1029,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
|
||||
$record11 = $datagenerator->create_entry($data1, [$field1->field->id => 'value11'], 0, ['Cats', 'Dogs']);
|
||||
$record21 = $datagenerator->create_entry($data2, [$field2->field->id => 'value21'], 0, ['Cats'], ['approved' => false]);
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1045,18 +1046,18 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->setUser($student);
|
||||
|
||||
// User can search data records inside a course.
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
$this->assertStringNotContainsString('value21', $res->content);
|
||||
|
||||
$recordtoupdate = new stdClass();
|
||||
$recordtoupdate = new \stdClass();
|
||||
$recordtoupdate->id = $record21;
|
||||
$recordtoupdate->approved = true;
|
||||
$DB->update_record('data_records', $recordtoupdate);
|
||||
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1074,7 +1075,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
|
||||
$fieldrecord = new StdClass();
|
||||
$fieldrecord = new \stdClass();
|
||||
$fieldrecord->name = 'field-1';
|
||||
$fieldrecord->type = 'text';
|
||||
|
||||
@@ -1089,7 +1090,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$field2 = $datagenerator->create_field($fieldrecord, $data2);
|
||||
$record11 = $datagenerator->create_entry($data1, [$field1->field->id => 'value11'], 0, ['Cats', 'Dogs']);
|
||||
$record21 = $datagenerator->create_entry($data2, [$field2->field->id => 'value21'], 0, ['Cats']);
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1106,7 +1107,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->setUser($student);
|
||||
|
||||
// User can search data records inside a course.
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1115,7 +1116,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$data2->timeviewto = time() + YEARSECS;
|
||||
$DB->update_record('data', $data2);
|
||||
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1133,7 +1134,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
|
||||
$fieldrecord = new StdClass();
|
||||
$fieldrecord = new \stdClass();
|
||||
$fieldrecord->name = 'field-1';
|
||||
$fieldrecord->type = 'text';
|
||||
|
||||
@@ -1144,7 +1145,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
|
||||
$record11 = $datagenerator->create_entry($data1, [$field1->field->id => 'value11'], 0, ['Cats', 'Dogs']);
|
||||
$record21 = $datagenerator->create_entry($data2, [$field2->field->id => 'value21'], 0, ['Cats']);
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1158,10 +1159,10 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course1->id, $studentrole->id, 'manual');
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can search data records inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$coursecontext = \context_course::instance($course1->id);
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1169,7 +1170,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course2->id, $studentrole->id, 'manual');
|
||||
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1190,7 +1191,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$groupa = $this->getDataGenerator()->create_group(array('courseid' => $course2->id, 'name' => 'groupA'));
|
||||
$groupb = $this->getDataGenerator()->create_group(array('courseid' => $course2->id, 'name' => 'groupB'));
|
||||
|
||||
$fieldrecord = new StdClass();
|
||||
$fieldrecord = new \stdClass();
|
||||
$fieldrecord->name = 'field-1';
|
||||
$fieldrecord->type = 'text';
|
||||
|
||||
@@ -1206,7 +1207,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$groupa->id, ['Cats']);
|
||||
$record22 = $datagenerator->create_entry($data2, [$field2->field->id => 'value22'],
|
||||
$groupb->id, ['Cats']);
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1223,7 +1224,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course2->id, $studentrole->id, 'manual');
|
||||
groups_add_member($groupa, $student);
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can search data records inside a course.
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
@@ -1233,7 +1234,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->assertStringNotContainsString('value22', $res->content);
|
||||
|
||||
groups_add_member($groupb, $student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
$res = mod_data_get_tagged_records($tag, false, 0, 0, 1, 0);
|
||||
|
||||
$this->assertStringContainsString('value11', $res->content);
|
||||
@@ -1260,7 +1261,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
);
|
||||
$data = $this->getDataGenerator()->create_module('data', $record);
|
||||
$cm = get_coursemodule_from_instance('data', $data->id, $course->id);
|
||||
$cm = cm_info::create($cm);
|
||||
$cm = \cm_info::create($cm);
|
||||
$this->setUser($student);
|
||||
|
||||
// Check that upon creation, the updates are only about the new configuration created.
|
||||
@@ -1284,7 +1285,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
foreach ($fieldtypes as $fieldtype) {
|
||||
// Creating variables dynamically.
|
||||
$fieldname = 'field-' . $count;
|
||||
$record = new StdClass();
|
||||
$record = new \stdClass();
|
||||
$record->name = $fieldname;
|
||||
$record->type = $fieldtype;
|
||||
$record->required = 1;
|
||||
@@ -1647,7 +1648,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype, $timestart = null) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'data';
|
||||
$event->courseid = $courseid;
|
||||
@@ -1660,7 +1661,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$event->timestart = time();
|
||||
}
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1684,13 +1685,13 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionentries' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('data', $data1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('data', $data2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('data', $data1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('data', $data2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => ['completionentries' => 3]];
|
||||
$moddefaults->completion = 2;
|
||||
|
||||
@@ -1698,7 +1699,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_data_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_data_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_data_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_data_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_data_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1991,7 +1992,7 @@ class mod_data_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
* @copyright 2016 Stephen Bourget
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_feedback;
|
||||
|
||||
use mod_feedback_completion;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/feedback/lib.php');
|
||||
@@ -30,7 +34,7 @@ require_once($CFG->dirroot . '/mod/feedback/lib.php');
|
||||
* @copyright 2016 Stephen Bourget
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function test_feedback_initialise() {
|
||||
$this->resetAfterTest();
|
||||
@@ -59,7 +63,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
foreach ($constructorparams as $params) {
|
||||
$structure = new mod_feedback_completion($params[0], $params[1], 0);
|
||||
$this->assertTrue($structure->is_open());
|
||||
$this->assertTrue($structure->get_cm() instanceof cm_info);
|
||||
$this->assertTrue($structure->get_cm() instanceof \cm_info);
|
||||
$this->assertEquals($feedback->cmid, $structure->get_cm()->id);
|
||||
$this->assertEquals($feedback->intro, $structure->get_feedback()->intro);
|
||||
}
|
||||
@@ -83,7 +87,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$params['timeclose'] = $timeclose;
|
||||
$feedback = $generator->create_instance($params);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
// Normal case, with existing course.
|
||||
$this->assertTrue(feedback_refresh_events($course->id));
|
||||
@@ -135,7 +139,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
);
|
||||
$feedback = $this->getDataGenerator()->create_module('feedback', $record);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id, $course->id);
|
||||
$cm = cm_info::create($cm);
|
||||
$cm = \cm_info::create($cm);
|
||||
|
||||
$this->setUser($student);
|
||||
// Check that upon creation, the updates are only about the new configuration created.
|
||||
@@ -417,7 +421,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$feedback = $this->getDataGenerator()->create_module('feedback', ['course' => $course->id]);
|
||||
$event = $this->create_action_event($course->id, $feedback->id, FEEDBACK_EVENT_TYPE_OPEN);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id, 'manual');
|
||||
|
||||
$this->setUser($user);
|
||||
@@ -445,7 +449,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$feedback = $this->getDataGenerator()->create_module('feedback', ['course' => $course->id]);
|
||||
$event = $this->create_action_event($course->id, $feedback->id, FEEDBACK_EVENT_TYPE_OPEN);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id, 'manual');
|
||||
|
||||
assign_capability('mod/feedback:complete', CAP_PROHIBIT, $studentrole->id, $context);
|
||||
@@ -478,7 +482,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$feedback = $this->getDataGenerator()->create_module('feedback', ['course' => $course->id]);
|
||||
$event = $this->create_action_event($course->id, $feedback->id, FEEDBACK_EVENT_TYPE_OPEN);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
@@ -514,7 +518,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$feedback = $this->getDataGenerator()->create_module('feedback', ['course' => $course->id]);
|
||||
$event = $this->create_action_event($course->id, $feedback->id, FEEDBACK_EVENT_TYPE_OPEN);
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
@@ -559,7 +563,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -593,7 +597,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -615,7 +619,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'feedback';
|
||||
$event->courseid = $courseid;
|
||||
@@ -624,7 +628,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,13 +652,13 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionsubmit' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('feedback', $feedback1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('feedback', $feedback2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('feedback', $feedback1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('feedback', $feedback2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => ['completionsubmit' => 1]];
|
||||
$moddefaults->completion = 2;
|
||||
|
||||
@@ -662,7 +666,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_feedback_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_feedback_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_feedback_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_feedback_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_feedback_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1023,7 +1027,7 @@ class mod_feedback_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();
|
||||
$feedbackgenerator = $generator->get_plugin_generator('mod_feedback');
|
||||
$timeopen = time();
|
||||
@@ -1082,7 +1086,7 @@ class mod_feedback_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();
|
||||
$feedbackgenerator = $generator->get_plugin_generator('mod_feedback');
|
||||
$timeopen = time();
|
||||
@@ -1143,7 +1147,7 @@ class mod_feedback_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_folder;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_folder_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Setup.
|
||||
@@ -68,7 +69,7 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$folder = $this->getDataGenerator()->create_module('folder', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($folder->cmid);
|
||||
$context = \context_module::instance($folder->cmid);
|
||||
$cm = get_coursemodule_from_instance('folder', $folder->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -90,7 +91,7 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -221,7 +222,7 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -257,7 +258,7 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Now, log out.
|
||||
@@ -282,7 +283,7 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'folder';
|
||||
$event->courseid = $courseid;
|
||||
@@ -291,6 +292,6 @@ class mod_folder_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +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/>.
|
||||
|
||||
/**
|
||||
* The module forums tests
|
||||
*
|
||||
* @package mod_forum
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_forum;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -29,7 +23,14 @@ require_once($CFG->dirroot . '/mod/forum/lib.php');
|
||||
require_once($CFG->dirroot . '/mod/forum/locallib.php');
|
||||
require_once($CFG->dirroot . '/rating/lib.php');
|
||||
|
||||
class mod_forum_lib_testcase extends advanced_testcase {
|
||||
/**
|
||||
* The mod_forum lib.php tests.
|
||||
*
|
||||
* @package mod_forum
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
// We must clear the subscription caches. This has to be done both before each test, and after in case of other
|
||||
@@ -49,7 +50,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$context = context_module::instance($forum->cmid);
|
||||
$context = \context_module::instance($forum->cmid);
|
||||
|
||||
$this->setUser($user->id);
|
||||
$fakepost = (object) array('id' => 123, 'message' => 'Yay!', 'discussion' => 100);
|
||||
@@ -66,7 +67,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
);
|
||||
$fi = $fs->create_file_from_string($dummy, 'Content of ' . $dummy->filename);
|
||||
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$sink = $this->redirectEvents();
|
||||
forum_trigger_content_uploaded_event($fakepost, $cm, 'some triggered from value');
|
||||
$events = $sink->get_events();
|
||||
@@ -80,7 +81,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($fakepost->discussion, $event->other['discussionid']);
|
||||
$this->assertCount(1, $event->other['pathnamehashes']);
|
||||
$this->assertEquals($fi->get_pathnamehash(), $event->other['pathnamehashes'][0]);
|
||||
$expected = new stdClass();
|
||||
$expected = new \stdClass();
|
||||
$expected->modulename = 'forum';
|
||||
$expected->name = 'some triggered from value';
|
||||
$expected->cmid = $forum->cmid;
|
||||
@@ -105,52 +106,52 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$course3 = $this->getDataGenerator()->create_course();
|
||||
|
||||
// Create 3 forums, one in each course.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = $this->getDataGenerator()->create_module('forum', $record);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course2->id;
|
||||
$forum2 = $this->getDataGenerator()->create_module('forum', $record);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course3->id;
|
||||
$forum3 = $this->getDataGenerator()->create_module('forum', $record);
|
||||
|
||||
// Add a second forum in course 1.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum4 = $this->getDataGenerator()->create_module('forum', $record);
|
||||
|
||||
// Add discussions to course 1 started by user1.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum1->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum4->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
// Add discussions to course2 started by user1.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course2->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum2->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
// Add discussions to course 3 started by user2.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course3->id;
|
||||
$record->userid = $user2->id;
|
||||
$record->forum = $forum3->id;
|
||||
$discussion3 = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
// Add post to course 3 by user1.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course3->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum3->id;
|
||||
@@ -271,7 +272,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$cache = cache::make('mod_forum', 'forum_is_tracked');
|
||||
$cache = \cache::make('mod_forum', 'forum_is_tracked');
|
||||
$useron = $this->getDataGenerator()->create_user(array('trackforums' => 1));
|
||||
$useroff = $this->getDataGenerator()->create_user(array('trackforums' => 0));
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
@@ -407,21 +408,21 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$forumoptional = $this->getDataGenerator()->create_module('forum', $options);
|
||||
|
||||
// Add discussions to the tracking off forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $useron->id;
|
||||
$record->forum = $forumoff->id;
|
||||
$discussionoff = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
// Add discussions to the tracking forced forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $useron->id;
|
||||
$record->forum = $forumforce->id;
|
||||
$discussionforce = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
// Add post to the tracking forced discussion.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $useroff->id;
|
||||
$record->forum = $forumforce->id;
|
||||
@@ -429,7 +430,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_post($record);
|
||||
|
||||
// Add discussions to the tracking optional forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $useron->id;
|
||||
$record->forum = $forumoptional->id;
|
||||
@@ -545,7 +546,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// Prevent the non-editing teacher from reading private replies in forum 2.
|
||||
$teacherroleid = $DB->get_field('role', 'id', ['shortname' => 'teacher']);
|
||||
$forum2cm = get_coursemodule_from_instance('forum', $forum2->id);
|
||||
$forum2context = context_module::instance($forum2cm->id);
|
||||
$forum2context = \context_module::instance($forum2cm->id);
|
||||
role_change_permission($teacherroleid, $forum2context, 'mod/forum:readprivatereplies', CAP_PREVENT);
|
||||
|
||||
// Create discussion by s1.
|
||||
@@ -672,7 +673,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// Prevent the non-editing teacher from reading private replies in forum 2.
|
||||
$teacherroleid = $DB->get_field('role', 'id', ['shortname' => 'teacher']);
|
||||
$forum2cm = get_coursemodule_from_instance('forum', $forum2->id);
|
||||
$forum2context = context_module::instance($forum2cm->id);
|
||||
$forum2context = \context_module::instance($forum2cm->id);
|
||||
role_change_permission($teacherroleid, $forum2context, 'mod/forum:readprivatereplies', CAP_PREVENT);
|
||||
|
||||
// Create discussion by s1.
|
||||
@@ -1118,7 +1119,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(1, $aftercount - $startcount);
|
||||
|
||||
// Set up the default page event to use the forum.
|
||||
$PAGE = new moodle_page();
|
||||
$PAGE = new \moodle_page();
|
||||
$PAGE->set_context($forumcontext);
|
||||
$PAGE->set_cm($forumcm, $course, $forum);
|
||||
|
||||
@@ -1139,7 +1140,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(0, $aftercount - $startcount);
|
||||
|
||||
// Now specify the page context of the course instead..
|
||||
$PAGE = new moodle_page();
|
||||
$PAGE = new \moodle_page();
|
||||
$PAGE->set_context($coursecontext);
|
||||
|
||||
// Now specify a context which is not a context_module.
|
||||
@@ -1177,9 +1178,9 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -1252,7 +1253,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$past = $now - 600;
|
||||
$future = $now + 600;
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -1426,9 +1427,9 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id, 'type' => 'blog'));
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -1496,7 +1497,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$past = $now - 600;
|
||||
$future = $now + 600;
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -1622,11 +1623,11 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$forum2 = $this->getDataGenerator()->create_module('forum', array('course' => $course->id, 'groupmode' => SEPARATEGROUPS));
|
||||
$cm1 = get_coursemodule_from_instance('forum', $forum1->id);
|
||||
$cm2 = get_coursemodule_from_instance('forum', $forum2->id);
|
||||
$context1 = context_module::instance($cm1->id);
|
||||
$context2 = context_module::instance($cm2->id);
|
||||
$context1 = \context_module::instance($cm1->id);
|
||||
$context2 = \context_module::instance($cm2->id);
|
||||
|
||||
// Creating discussions in both forums.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum1->id;
|
||||
@@ -1821,11 +1822,11 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
'groupmode' => SEPARATEGROUPS));
|
||||
$cm1 = get_coursemodule_from_instance('forum', $forum1->id);
|
||||
$cm2 = get_coursemodule_from_instance('forum', $forum2->id);
|
||||
$context1 = context_module::instance($cm1->id);
|
||||
$context2 = context_module::instance($cm2->id);
|
||||
$context1 = \context_module::instance($cm1->id);
|
||||
$context2 = \context_module::instance($cm2->id);
|
||||
|
||||
// Creating blog posts in both forums.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user1->id;
|
||||
$record->forum = $forum1->id;
|
||||
@@ -2086,7 +2087,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$context = context_module::instance($forum->cmid);
|
||||
$context = \context_module::instance($forum->cmid);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
$student = $this->getDataGenerator()->create_user();
|
||||
@@ -2104,7 +2105,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
// Create a discussion with some replies.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $forum->course;
|
||||
$record->forum = $forum->id;
|
||||
$record->userid = $student->id;
|
||||
@@ -2113,7 +2114,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$replyto = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
|
||||
|
||||
// Create a couple of standard replies.
|
||||
$post = new stdClass();
|
||||
$post = new \stdClass();
|
||||
$post->userid = $student->id;
|
||||
$post->discussion = $discussion->id;
|
||||
$post->parent = $replyto->id;
|
||||
@@ -2123,7 +2124,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
// Create a private reply post from the teacher back to the student.
|
||||
$reply = new stdClass();
|
||||
$reply = new \stdClass();
|
||||
$reply->userid = $teacher->id;
|
||||
$reply->discussion = $discussion->id;
|
||||
$reply->parent = $replyto->id;
|
||||
@@ -2169,7 +2170,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($forum->cmid);
|
||||
$context = \context_module::instance($forum->cmid);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -2192,7 +2193,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -2211,7 +2212,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$discussion = $this->create_single_discussion_with_replies($forum, $USER, 2);
|
||||
|
||||
$context = context_module::instance($forum->cmid);
|
||||
$context = \context_module::instance($forum->cmid);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -2249,7 +2250,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// Setup the content.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$forum = $this->getDataGenerator()->create_module('forum', $record);
|
||||
|
||||
@@ -2281,7 +2282,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$generator = self::getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $forum->course;
|
||||
$record->forum = $forum->id;
|
||||
$record->userid = $user->id;
|
||||
@@ -2291,7 +2292,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$replyto = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
|
||||
|
||||
// Create the replies.
|
||||
$post = new stdClass();
|
||||
$post = new \stdClass();
|
||||
$post->userid = $user->id;
|
||||
$post->discussion = $discussion->id;
|
||||
$post->parent = $replyto->id;
|
||||
@@ -2315,7 +2316,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$generator = self::getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $forum->course;
|
||||
$record->forum = $forum->id;
|
||||
$record->userid = $user->id;
|
||||
@@ -2326,7 +2327,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$replyto = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
|
||||
|
||||
// Create the replies.
|
||||
$post = new stdClass();
|
||||
$post = new \stdClass();
|
||||
$post->userid = $user->id;
|
||||
$post->discussion = $discussion->id;
|
||||
$post->parent = $replyto->id;
|
||||
@@ -2350,14 +2351,14 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Setup test data.
|
||||
$course = new stdClass();
|
||||
$course = new \stdClass();
|
||||
$course->groupmode = SEPARATEGROUPS;
|
||||
$course->groupmodeforce = true;
|
||||
$course = $this->getDataGenerator()->create_course($course);
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$generator = self::getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
// Create users.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
@@ -2379,7 +2380,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
groups_add_member($group2, $user3);
|
||||
groups_add_member($group2, $user4);
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $forum->course;
|
||||
$record->forum = $forum->id;
|
||||
$record->userid = $user1->id;
|
||||
@@ -2389,14 +2390,14 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// Retrieve the first post.
|
||||
$post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
|
||||
|
||||
$ratingoptions = new stdClass;
|
||||
$ratingoptions = new \stdClass;
|
||||
$ratingoptions->context = $context;
|
||||
$ratingoptions->ratingarea = 'post';
|
||||
$ratingoptions->component = 'mod_forum';
|
||||
$ratingoptions->itemid = $post->id;
|
||||
$ratingoptions->scaleid = 2;
|
||||
$ratingoptions->userid = $user2->id;
|
||||
$rating = new rating($ratingoptions);
|
||||
$rating = new \rating($ratingoptions);
|
||||
$rating->update_rating(2);
|
||||
|
||||
// Now try to access it as various users.
|
||||
@@ -2461,7 +2462,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
self::getDataGenerator()->enrol_user($user3->id, $course->id, $role->id);
|
||||
|
||||
// Forum forcing separate gropus.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$forum = self::getDataGenerator()->create_module('forum', $record, array('groupmode' => SEPARATEGROUPS));
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
@@ -2574,11 +2575,11 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($user->id, $course->id);
|
||||
|
||||
// Forum forcing separate gropus.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$forum = self::getDataGenerator()->create_module('forum', $record, array('groupmode' => SEPARATEGROUPS));
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
self::setUser($user);
|
||||
|
||||
@@ -2637,7 +2638,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertTrue($can);
|
||||
|
||||
// Post now.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -2675,12 +2676,12 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, 'editingteacher');
|
||||
|
||||
// Forum forcing separate gropus.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->cutoffdate = time() - 1;
|
||||
$forum = self::getDataGenerator()->create_module('forum', $record);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$context = \context_module::instance($cm->id);
|
||||
|
||||
self::setUser($student);
|
||||
|
||||
@@ -2716,7 +2717,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertFalse(forum_user_has_posted_discussion($forum->id, $other->id));
|
||||
|
||||
// Post in the forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -2748,7 +2749,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertFalse(forum_user_has_posted_discussion($forum2->id, $author->id));
|
||||
|
||||
// Post in the forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum1->id;
|
||||
@@ -2788,7 +2789,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertFalse(forum_user_has_posted_discussion($forum->id, $author->id, $group2->id));
|
||||
|
||||
// Post in one group.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -2801,7 +2802,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertFalse(forum_user_has_posted_discussion($forum->id, $author->id, $group2->id));
|
||||
|
||||
// Post in the other group.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -2831,7 +2832,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
mod_forum_myprofile_navigation($tree, $user, $iscurrentuser, $course);
|
||||
$reflector = new ReflectionObject($tree);
|
||||
$reflector = new \ReflectionObject($tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('forumposts', $nodes->getValue($tree));
|
||||
@@ -2856,7 +2857,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
mod_forum_myprofile_navigation($tree, $USER, $iscurrentuser, $course);
|
||||
$reflector = new ReflectionObject($tree);
|
||||
$reflector = new \ReflectionObject($tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('forumposts', $nodes->getValue($tree));
|
||||
@@ -2881,7 +2882,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
mod_forum_myprofile_navigation($tree, $user, $iscurrentuser, $course);
|
||||
$reflector = new ReflectionObject($tree);
|
||||
$reflector = new \ReflectionObject($tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('forumposts', $nodes->getValue($tree));
|
||||
@@ -2922,13 +2923,13 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Create 4 discussions in all participants group and group1, where the first
|
||||
// discussion is pinned in each group.
|
||||
$allrecord = new stdClass();
|
||||
$allrecord = new \stdClass();
|
||||
$allrecord->course = $course1->id;
|
||||
$allrecord->userid = $author->id;
|
||||
$allrecord->forum = $forum1->id;
|
||||
$allrecord->pinned = FORUM_DISCUSSION_PINNED;
|
||||
|
||||
$group1record = new stdClass();
|
||||
$group1record = new \stdClass();
|
||||
$group1record->course = $course1->id;
|
||||
$group1record->userid = $author->id;
|
||||
$group1record->forum = $forum1->id;
|
||||
@@ -3032,7 +3033,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($user->id, $course->id);
|
||||
|
||||
// Create a forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$forum = $this->getDataGenerator()->create_module('forum', (object) array(
|
||||
'course' => $course->id,
|
||||
@@ -3044,7 +3045,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$discussions = array();
|
||||
$discussiongenerator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -3104,7 +3105,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($user->id, $course->id);
|
||||
|
||||
// Create a forum.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$forum = $this->getDataGenerator()->create_module('forum', (object) array(
|
||||
'course' => $course->id,
|
||||
@@ -3116,7 +3117,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$discussions = array();
|
||||
$discussiongenerator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->userid = $user->id;
|
||||
$record->forum = $forum->id;
|
||||
@@ -3210,8 +3211,8 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
* Test the forum_discussion_is_locked function.
|
||||
*
|
||||
* @dataProvider forum_discussion_is_locked_provider
|
||||
* @param stdClass $forum
|
||||
* @param stdClass $discussion
|
||||
* @param \stdClass $forum
|
||||
* @param \stdClass $discussion
|
||||
* @param bool $expect
|
||||
*/
|
||||
public function test_forum_discussion_is_locked($forum, $discussion, $expect) {
|
||||
@@ -3319,7 +3320,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
* Test the forum_is_due_date_reached function.
|
||||
*
|
||||
* @dataProvider forum_is_due_date_reached_provider
|
||||
* @param stdClass $forum
|
||||
* @param \stdClass $forum
|
||||
* @param bool $expect
|
||||
*/
|
||||
public function test_forum_is_due_date_reached($forum, $expect) {
|
||||
@@ -3609,7 +3610,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -3648,7 +3649,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -3686,7 +3687,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$post23 = $forumgenerator->create_content($forum2, array('tags' => array('mice', 'Cats')));
|
||||
$post31 = $forumgenerator->create_content($forum3, array('tags' => array('mice', 'Cats')));
|
||||
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
@@ -3724,7 +3725,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course1->id, $studentrole->id, 'manual');
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course2->id, $studentrole->id, 'manual');
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can not see posts in course 3 because he is not enrolled.
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
@@ -3734,7 +3735,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post31->subject.'/', $res->content);
|
||||
|
||||
// User can search forum posts inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$coursecontext = \context_course::instance($course1->id);
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$post = */0);
|
||||
$this->assertMatchesRegularExpression('/'.$post11->subject.'/', $res->content);
|
||||
@@ -3758,7 +3759,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'forum';
|
||||
$event->courseid = $courseid;
|
||||
@@ -3767,7 +3768,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3795,13 +3796,13 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
'completionreplies' => 0,
|
||||
'completionposts' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('forum', $forum1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('forum', $forum2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('forum', $forum1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('forum', $forum2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => [
|
||||
'completiondiscussions' => 3,
|
||||
'completionreplies' => 3,
|
||||
@@ -3817,7 +3818,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_forum_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_forum_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_forum_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_forum_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_forum_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3828,7 +3829,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$context = context_module::instance($forum->cmid);
|
||||
$context = \context_module::instance($forum->cmid);
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
|
||||
$author = $this->getDataGenerator()->create_user();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2018 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_forum;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,7 +36,7 @@ require_once($CFG->dirroot . '/mod/forum/lib.php');
|
||||
* @copyright 2018 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_forum_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
public function test_forum_update_calendar() {
|
||||
global $DB;
|
||||
|
||||
@@ -70,4 +71,4 @@ class mod_forum_locallib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($time, $event->timestart);
|
||||
$this->assertEquals($time, $event->timesort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 mod_glossary;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,7 +36,7 @@ require_once($CFG->dirroot . '/mod/glossary/locallib.php');
|
||||
* @copyright 2015 Frédéric Massart - FMCorz.net
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function test_glossary_view() {
|
||||
global $CFG;
|
||||
@@ -57,11 +58,11 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
));
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($u1->id, $c1->id);
|
||||
$modinfo = course_modinfo::instance($c1->id);
|
||||
$modinfo = \course_modinfo::instance($c1->id);
|
||||
$cm1 = $modinfo->get_cm($g1->cmid);
|
||||
$cm2 = $modinfo->get_cm($g2->cmid);
|
||||
$ctx1 = $cm1->context;
|
||||
$completion = new completion_info($c1);
|
||||
$completion = new \completion_info($c1);
|
||||
|
||||
$this->setUser($u1);
|
||||
|
||||
@@ -102,7 +103,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$g1 = $this->getDataGenerator()->create_module('glossary', array('course' => $c1->id));
|
||||
$e1 = $gg->create_content($g1);
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$ctx = context_module::instance($g1->cmid);
|
||||
$ctx = \context_module::instance($g1->cmid);
|
||||
$this->getDataGenerator()->enrol_user($u1->id, $c1->id);
|
||||
|
||||
// Assertions.
|
||||
@@ -257,7 +258,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -296,7 +297,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the user.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -318,7 +319,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'glossary';
|
||||
$event->courseid = $courseid;
|
||||
@@ -327,7 +328,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,13 +352,13 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionentries' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('glossary', $glossary1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('glossary', $glossary2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('glossary', $glossary1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('glossary', $glossary2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => ['completionentries' => 3]];
|
||||
$moddefaults->completion = 2;
|
||||
|
||||
@@ -365,7 +366,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_glossary_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_glossary_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_glossary_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_glossary_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_glossary_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
public function test_mod_glossary_get_tagged_entries() {
|
||||
@@ -402,7 +403,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$entry23 = $glossarygenerator->create_content($glossary2, array('tags' => array('mice', 'Cats')));
|
||||
$entry31 = $glossarygenerator->create_content($glossary3, array('tags' => array('mice', 'Cats')));
|
||||
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
// Get first page of tagged entries (first 5 entries).
|
||||
@@ -439,7 +440,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can not see entries in course 3 because he is not enrolled.
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
@@ -449,7 +450,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry31->concept.'/', $res->content);
|
||||
|
||||
// User can search glossary entries inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$coursecontext = \context_course::instance($course1->id);
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$entry = */0);
|
||||
$this->assertMatchesRegularExpression('/'.$entry11->concept.'/', $res->content);
|
||||
@@ -517,7 +518,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
$this->setUser($student);
|
||||
$entry = $gg->create_content($glossary);
|
||||
$context = context_module::instance($glossary->cmid);
|
||||
$context = \context_module::instance($glossary->cmid);
|
||||
|
||||
// Test student can delete.
|
||||
$this->assertTrue(mod_glossary_can_delete_entry($entry, $glossary, $context));
|
||||
@@ -551,7 +552,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
$this->setUser($student);
|
||||
$entry = $gg->create_content($glossary);
|
||||
$context = context_module::instance($glossary->cmid);
|
||||
$context = \context_module::instance($glossary->cmid);
|
||||
|
||||
// Test student can always delete when edit always is set to 1.
|
||||
$entry->timecreated = time() - 2 * $CFG->maxeditingtime;
|
||||
@@ -581,13 +582,13 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $course->id;
|
||||
$record->assessed = RATING_AGGREGATE_AVERAGE;
|
||||
$scale = $this->getDataGenerator()->create_scale(['scale' => 'A,B,C,D']);
|
||||
$record->scale = "-$scale->id";
|
||||
$glossary = $this->getDataGenerator()->create_module('glossary', $record);
|
||||
$context = context_module::instance($glossary->cmid);
|
||||
$context = \context_module::instance($glossary->cmid);
|
||||
$cm = get_coursemodule_from_instance('glossary', $glossary->id);
|
||||
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
@@ -601,7 +602,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
);
|
||||
|
||||
// Rate the entry as user2.
|
||||
$rating1 = new stdClass();
|
||||
$rating1 = new \stdClass();
|
||||
$rating1->contextid = $context->id;
|
||||
$rating1->component = 'mod_glossary';
|
||||
$rating1->ratingarea = 'entry';
|
||||
@@ -627,7 +628,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(0, $DB->count_records('glossary_entries', ['id' => $entry->id]));
|
||||
$this->assertEquals(0, $DB->count_records('glossary_alias', ['entryid' => $entry->id]));
|
||||
$this->assertEquals(0, $DB->count_records('rating', ['component' => 'mod_glossary', 'itemid' => $entry->id]));
|
||||
$this->assertEmpty(core_tag_tag::get_by_name(0, 'Cats'));
|
||||
$this->assertEmpty(\core_tag_tag::get_by_name(0, 'Cats'));
|
||||
}
|
||||
|
||||
public function test_mod_glossary_delete_entry_imported() {
|
||||
@@ -641,7 +642,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$glossary1 = $this->getDataGenerator()->create_module('glossary', ['course' => $course->id]);
|
||||
$glossary2 = $this->getDataGenerator()->create_module('glossary', ['course' => $course->id]);
|
||||
|
||||
$context = context_module::instance($glossary2->cmid);
|
||||
$context = \context_module::instance($glossary2->cmid);
|
||||
$cm = get_coursemodule_from_instance('glossary', $glossary2->id);
|
||||
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
@@ -668,7 +669,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($glossary1->id, $DB->get_field('glossary_entries', 'glossaryid', ['id' => $entry2->id]));
|
||||
|
||||
// Tags.
|
||||
$this->assertEmpty(core_tag_tag::get_by_name(0, 'Cats'));
|
||||
$this->assertEmpty(\core_tag_tag::get_by_name(0, 'Cats'));
|
||||
}
|
||||
|
||||
public function test_mod_glossary_can_update_entry_users() {
|
||||
@@ -684,7 +685,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
$this->setUser($student);
|
||||
$entry = $gg->create_content($glossary);
|
||||
$context = context_module::instance($glossary->cmid);
|
||||
$context = \context_module::instance($glossary->cmid);
|
||||
$cm = get_coursemodule_from_instance('glossary', $glossary->id);
|
||||
|
||||
// Test student can update.
|
||||
@@ -719,7 +720,7 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
$gg = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
|
||||
$this->setUser($student);
|
||||
$entry = $gg->create_content($glossary);
|
||||
$context = context_module::instance($glossary->cmid);
|
||||
$context = \context_module::instance($glossary->cmid);
|
||||
$cm = get_coursemodule_from_instance('glossary', $glossary->id);
|
||||
|
||||
// Test student can always update when edit always is set to 1.
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @copyright 2015 Juan Leyva <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_imscp;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/mod/imscp/lib.php');
|
||||
* @copyright 2015 Juan Leyva <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
public function test_export_contents() {
|
||||
global $DB, $USER;
|
||||
@@ -80,7 +80,7 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$imscp = $this->getDataGenerator()->create_module('imscp', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($imscp->cmid);
|
||||
$context = \context_module::instance($imscp->cmid);
|
||||
$cm = get_coursemodule_from_instance('imscp', $imscp->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -102,7 +102,7 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -294,7 +294,7 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -316,7 +316,7 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'imscp';
|
||||
$event->courseid = $courseid;
|
||||
@@ -325,6 +325,6 @@ class mod_imscp_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_label;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_label_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Set up.
|
||||
@@ -167,7 +168,7 @@ class mod_label_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -201,7 +202,7 @@ class mod_label_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -223,7 +224,7 @@ class mod_label_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'label';
|
||||
$event->courseid = $courseid;
|
||||
@@ -232,6 +233,6 @@ class mod_label_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
namespace mod_lesson;
|
||||
|
||||
use lesson;
|
||||
use mod_lesson_external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +38,7 @@ require_once($CFG->dirroot . '/mod/lesson/lib.php');
|
||||
* @copyright 2017 Jun Pataleta
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
/**
|
||||
* Test for lesson_get_group_override_priorities().
|
||||
*/
|
||||
@@ -91,7 +95,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$course = new stdClass();
|
||||
$course = new \stdClass();
|
||||
$course->groupmode = SEPARATEGROUPS;
|
||||
$course->groupmodeforce = true;
|
||||
$course = $this->getDataGenerator()->create_course($course);
|
||||
@@ -123,7 +127,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
// Convert to a lesson object.
|
||||
$lesson = new lesson($lessonmodule);
|
||||
$cm = $lesson->cm;
|
||||
$cm = cm_info::create($cm);
|
||||
$cm = \cm_info::create($cm);
|
||||
|
||||
// Check that upon creation, the updates are only about the new configuration created.
|
||||
$onehourago = time() - HOURSECS;
|
||||
@@ -207,7 +211,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Now, teacher can't access all groups.
|
||||
groups_add_member($group1, $teacherg1);
|
||||
assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, context_module::instance($cm->id));
|
||||
assign_capability('moodle/site:accessallgroups', CAP_PROHIBIT, $teacherrole->id, \context_module::instance($cm->id));
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
$updates = lesson_check_updates_since($cm, $onehourago);
|
||||
// I will see only the studentg1 updates.
|
||||
@@ -666,7 +670,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -700,7 +704,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -722,7 +726,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'lesson';
|
||||
$event->courseid = $courseid;
|
||||
@@ -730,7 +734,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
$event->type = CALENDAR_EVENT_TYPE_ACTION;
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -756,13 +760,13 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
'completionendreached' => 0,
|
||||
'completiontimespent' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('lesson', $lesson1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('lesson', $lesson2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('lesson', $lesson1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('lesson', $lesson2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => [
|
||||
'completionendreached' => 1,
|
||||
'completiontimespent' => 3600
|
||||
@@ -776,7 +780,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1067,7 +1071,7 @@ class mod_lesson_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
* @copyright 2016 Adrian Greeve <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_lesson;
|
||||
|
||||
use lesson;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -37,7 +40,7 @@ require_once($CFG->dirroot.'/mod/lesson/locallib.php');
|
||||
* @copyright 2016 Adrian Greeve <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_lesson_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test duplicating a lesson page element.
|
||||
@@ -134,16 +137,16 @@ class mod_lesson_locallib_testcase extends advanced_testcase {
|
||||
// Let's test lesson 1 closes in three hours for user student 1 since member of group 1.
|
||||
// lesson 2 closes in two hours.
|
||||
$this->setUser($student1id);
|
||||
$params = new stdClass();
|
||||
$params = new \stdClass();
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson1->id;
|
||||
$object->userdeadline = $basetimestamp + 10800; // The overriden deadline for lesson 1.
|
||||
|
||||
$comparearray[$lesson1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson2->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The unchanged deadline for lesson 2.
|
||||
|
||||
@@ -153,16 +156,16 @@ class mod_lesson_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Let's test lesson 1 closes in two hours (the original value) for user student 3 since member of no group.
|
||||
$this->setUser($student3id);
|
||||
$params = new stdClass();
|
||||
$params = new \stdClass();
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson1->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The original deadline for lesson 1.
|
||||
|
||||
$comparearray[$lesson1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson2->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The original deadline for lesson 2.
|
||||
|
||||
@@ -183,13 +186,13 @@ class mod_lesson_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($student2id);
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson1->id;
|
||||
$object->userdeadline = $basetimestamp + 14400; // The overriden deadline for lesson 1.
|
||||
|
||||
$comparearray[$lesson1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson2->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The unchanged deadline for lesson 2.
|
||||
|
||||
@@ -202,13 +205,13 @@ class mod_lesson_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($teacherid);
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson1->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The unchanged deadline for lesson 1.
|
||||
|
||||
$comparearray[$lesson1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $lesson2->id;
|
||||
$object->userdeadline = $basetimestamp + 7200; // The unchanged deadline for lesson 2.
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_lti;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,7 +36,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_lti_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Prepares things before this test case is initialised
|
||||
@@ -61,7 +62,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$lti = $this->getDataGenerator()->create_module('lti', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($lti->cmid);
|
||||
$context = \context_module::instance($lti->cmid);
|
||||
$cm = get_coursemodule_from_instance('lti', $lti->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -83,7 +84,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -214,7 +215,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -248,7 +249,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Now, log out.
|
||||
@@ -290,7 +291,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for $student1.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student1->id);
|
||||
|
||||
// Now, log in as $student2.
|
||||
@@ -315,7 +316,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'lti';
|
||||
$event->courseid = $courseid;
|
||||
@@ -324,7 +325,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +401,7 @@ class mod_lti_lib_testcase extends advanced_testcase {
|
||||
'1',
|
||||
'default module content item',
|
||||
new \core_course\local\entity\string_title('Content item title'),
|
||||
new moodle_url(''),
|
||||
new \moodle_url(''),
|
||||
'icon',
|
||||
'Description of the module',
|
||||
MOD_ARCHETYPE_OTHER,
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
* @author Chris Scribner
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_lti;
|
||||
|
||||
use mod_lti_external;
|
||||
use mod_lti_testcase;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
@@ -61,12 +65,12 @@ require_once($CFG->dirroot . '/mod/lti/tests/mod_lti_testcase.php');
|
||||
* @copyright Copyright (c) 2012 Moodlerooms Inc. (http://www.moodlerooms.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
class locallib_test extends mod_lti_testcase {
|
||||
|
||||
public function test_split_custom_parameters() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$tool = new stdClass();
|
||||
$tool = new \stdClass();
|
||||
$tool->enabledcapability = '';
|
||||
$tool->parameter = '';
|
||||
$tool->ltiversion = 'LTI-1p0';
|
||||
@@ -280,8 +284,8 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
* Tests lti_prepare_type_for_save's handling of the "Force SSL" configuration.
|
||||
*/
|
||||
public function test_lti_prepare_type_for_save_forcessl() {
|
||||
$type = new stdClass();
|
||||
$config = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$config = new \stdClass();
|
||||
|
||||
// Try when the forcessl config property is not set.
|
||||
lti_prepare_type_for_save($type, $config);
|
||||
@@ -308,7 +312,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
* Tests lti_load_type_from_cartridge and lti_load_type_if_cartridge
|
||||
*/
|
||||
public function test_lti_load_type_from_cartridge() {
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->lti_toolurl = $this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml');
|
||||
|
||||
lti_load_type_if_cartridge($type);
|
||||
@@ -324,7 +328,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
* Tests lti_load_tool_from_cartridge and lti_load_tool_if_cartridge
|
||||
*/
|
||||
public function test_lti_load_tool_from_cartridge() {
|
||||
$lti = new stdClass();
|
||||
$lti = new \stdClass();
|
||||
$lti->toolurl = $this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml');
|
||||
|
||||
lti_load_tool_if_cartridge($lti);
|
||||
@@ -348,8 +352,8 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
$proxy = mod_lti_external::create_tool_proxy('Test proxy', $this->getExternalTestFileUrl('/test.html'), array(), array());
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$data = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->lti_contentitem = true;
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
@@ -362,7 +366,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
$typeconfig = lti_get_type_config($typeid);
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$returnurl = new moodle_url('/');
|
||||
$returnurl = new \moodle_url('/');
|
||||
|
||||
// Default parameters.
|
||||
$result = lti_build_content_item_selection_request($typeid, $course, $returnurl);
|
||||
@@ -434,7 +438,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
|
||||
$this->setAdminUser();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$returnurl = new moodle_url('/');
|
||||
$returnurl = new \moodle_url('/');
|
||||
|
||||
// Should throw Exception on non-existent tool type.
|
||||
$this->expectException('moodle_exception');
|
||||
@@ -450,8 +454,8 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$data = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->lti_contentitem = true;
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
@@ -460,7 +464,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
|
||||
$typeid = lti_add_type($type, $data);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$returnurl = new moodle_url('/');
|
||||
$returnurl = new \moodle_url('/');
|
||||
|
||||
// Should throw coding_exception on non-array media types.
|
||||
$mediatypes = 'image/*,video/*';
|
||||
@@ -477,8 +481,8 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$data = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->lti_contentitem = true;
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
@@ -487,7 +491,7 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
|
||||
$typeid = lti_add_type($type, $data);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$returnurl = new moodle_url('/');
|
||||
$returnurl = new \moodle_url('/');
|
||||
|
||||
// Should throw coding_exception on non-array presentation targets.
|
||||
$targets = 'frame,iframe';
|
||||
@@ -1067,13 +1071,13 @@ class mod_lti_locallib_testcase extends mod_lti_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_publickey = '-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnzyis1ZjfNB0bBgKFMSv
|
||||
vkTtwlvBsaJq7S5wA+kzeVOVpVWwkWdVha4s38XM/pa/yr47av7+z3VTmvDRyAHc
|
||||
@@ -1104,13 +1108,13 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_publickeyset = dirname(__FILE__) . '/fixtures/test_keyset';
|
||||
|
||||
$config->lti_keytype = LTI_JWK_KEYSET;
|
||||
@@ -1147,14 +1151,14 @@ MwIDAQAB
|
||||
$proxy = mod_lti_external::create_tool_proxy('Test proxy', $this->getExternalTestFileUrl('/test.html'), array(), array());
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->toolproxyid = $proxy->id;
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
$data->lti_contentitem = true;
|
||||
|
||||
$typeid = lti_add_type($type, $data);
|
||||
@@ -1172,14 +1176,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = 'consumerkey';
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
$this->expectExceptionMessage(get_string('errorincorrectconsumerkey', 'mod_lti'));
|
||||
@@ -1194,14 +1198,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = 'consumerkey';
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_keytype = LTI_RSA_KEY;
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
@@ -1253,38 +1257,38 @@ MwIDAQAB
|
||||
$strgraph = '@graph';
|
||||
$strtype = '@type';
|
||||
|
||||
$objgraph = new stdClass();
|
||||
$objgraph = new \stdClass();
|
||||
$objgraph->url = 'http://example.com/messages/launch';
|
||||
$objgraph->title = 'Test title';
|
||||
$objgraph->text = 'Test text';
|
||||
$objgraph->placementAdvice = new stdClass();
|
||||
$objgraph->placementAdvice = new \stdClass();
|
||||
$objgraph->placementAdvice->presentationDocumentTarget = 'iframe';
|
||||
$objgraph->{$strtype} = 'LtiLinkItem';
|
||||
$objgraph->mediaType = 'application\/vnd.ims.lti.v1.ltilink';
|
||||
|
||||
$objgraph2 = new stdClass();
|
||||
$objgraph2 = new \stdClass();
|
||||
$objgraph2->url = 'http://example.com/messages/launch2';
|
||||
$objgraph2->title = 'Test title2';
|
||||
$objgraph2->text = 'Test text2';
|
||||
$objgraph2->placementAdvice = new stdClass();
|
||||
$objgraph2->placementAdvice = new \stdClass();
|
||||
$objgraph2->placementAdvice->presentationDocumentTarget = 'iframe';
|
||||
$objgraph2->placementAdvice->displayHeight = 200;
|
||||
$objgraph2->placementAdvice->displayWidth = 300;
|
||||
$objgraph2->{$strtype} = 'LtiLinkItem';
|
||||
$objgraph2->mediaType = 'application\/vnd.ims.lti.v1.ltilink';
|
||||
|
||||
$objgraph3 = new stdClass();
|
||||
$objgraph3 = new \stdClass();
|
||||
$objgraph3->url = 'http://example.com/messages/launch3';
|
||||
$objgraph3->title = 'Test title3';
|
||||
$objgraph3->text = 'Test text3';
|
||||
$objgraph3->placementAdvice = new stdClass();
|
||||
$objgraph3->placementAdvice = new \stdClass();
|
||||
$objgraph3->placementAdvice->presentationDocumentTarget = 'window';
|
||||
$objgraph3->placementAdvice->displayHeight = 400;
|
||||
$objgraph3->placementAdvice->windowTarget = 'test-win';
|
||||
$objgraph3->{$strtype} = 'LtiLinkItem';
|
||||
$objgraph3->mediaType = 'application\/vnd.ims.lti.v1.ltilink';
|
||||
|
||||
$expected = new stdClass();
|
||||
$expected = new \stdClass();
|
||||
$expected->{$strcontext} = 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem';
|
||||
$expected->{$strgraph} = [];
|
||||
$expected->{$strgraph}[] = $objgraph;
|
||||
@@ -1301,10 +1305,10 @@ MwIDAQAB
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->name = "Test tool";
|
||||
$type->baseurl = "http://example.com";
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_acceptgrades = LTI_SETTING_DELEGATE;
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
@@ -1344,10 +1348,10 @@ MwIDAQAB
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->name = "Test tool";
|
||||
$type->baseurl = "http://example.com";
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_acceptgrades = LTI_SETTING_DELEGATE;
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
@@ -1402,10 +1406,10 @@ MwIDAQAB
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->name = "Test tool";
|
||||
$type->baseurl = "http://example.com";
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_lti');
|
||||
@@ -1446,14 +1450,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = 'consumerkey';
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
$params = [];
|
||||
@@ -1492,14 +1496,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = 'sso.example.com';
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_publickey = '-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnzyis1ZjfNB0bBgKFMSv
|
||||
vkTtwlvBsaJq7S5wA+kzeVOVpVWwkWdVha4s38XM/pa/yr47av7+z3VTmvDRyAHc
|
||||
@@ -1532,13 +1536,13 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$typeconfig = new stdClass();
|
||||
$typeconfig = new \stdClass();
|
||||
$typeconfig->lti_acceptgrades = true;
|
||||
|
||||
$typeid = lti_add_type($type, $typeconfig);
|
||||
@@ -1563,14 +1567,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = "Test client ID";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
@@ -1597,14 +1601,14 @@ MwIDAQAB
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a tool type, associated with that proxy.
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = "Test client ID";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
|
||||
$typeid = lti_add_type($type, $config);
|
||||
|
||||
@@ -1640,7 +1644,7 @@ MwIDAQAB
|
||||
]
|
||||
);
|
||||
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_clientid = 'some-client-id';
|
||||
$config->typeid = 'some-type-id';
|
||||
$config->lti_toolurl = 'some-lti-tool-url';
|
||||
@@ -1662,7 +1666,7 @@ MwIDAQAB
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_organizationid = '';
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$type = $this->create_type($config);
|
||||
@@ -1678,7 +1682,7 @@ MwIDAQAB
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_organizationid = '';
|
||||
$config->lti_organizationid_default = LTI_DEFAULT_ORGID_SITEHOST;
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
@@ -1695,7 +1699,7 @@ MwIDAQAB
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_organizationid = '';
|
||||
$config->lti_organizationid_default = LTI_DEFAULT_ORGID_SITEID;
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
@@ -1712,7 +1716,7 @@ MwIDAQAB
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
$config = new stdClass();
|
||||
$config = new \stdClass();
|
||||
$config->lti_organizationid = 'overridden!';
|
||||
$config->lti_organizationid_default = LTI_DEFAULT_ORGID_SITEID;
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
@@ -1762,7 +1766,7 @@ MwIDAQAB
|
||||
if ($switchedto) {
|
||||
$this->setUser($user);
|
||||
$role = $DB->get_record('role', array('shortname' => $switchedto));
|
||||
role_switch($role->id, context_course::instance($course->id));
|
||||
role_switch($role->id, \context_course::instance($course->id));
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, lti_get_ims_role($user, 0, $course->id, $islti2));
|
||||
@@ -1949,14 +1953,14 @@ MwIDAQAB
|
||||
* @return object tool.
|
||||
*/
|
||||
private function create_type(object $config) {
|
||||
$type = new stdClass();
|
||||
$type = new \stdClass();
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->name = "Test tool";
|
||||
$type->description = "Example description";
|
||||
$type->clientid = "Test client ID";
|
||||
$type->baseurl = $this->getExternalTestFileUrl('/test.html');
|
||||
|
||||
$configbase = new stdClass();
|
||||
$configbase = new \stdClass();
|
||||
$configbase->lti_acceptgrades = LTI_SETTING_NEVER;
|
||||
$configbase->lti_sendname = LTI_SETTING_NEVER;
|
||||
$configbase->lti_sendemailaddr = LTI_SETTING_NEVER;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_page;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_page_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Prepares things before this test case is initialised
|
||||
@@ -61,7 +62,7 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$page = $this->getDataGenerator()->create_module('page', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($page->cmid);
|
||||
$context = \context_module::instance($page->cmid);
|
||||
$cm = get_coursemodule_from_instance('page', $page->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -84,7 +85,7 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -173,7 +174,7 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -207,7 +208,7 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'page';
|
||||
$event->courseid = $courseid;
|
||||
@@ -216,6 +217,6 @@ class mod_page_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
+31
-28
@@ -22,7 +22,10 @@
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
namespace mod_quiz;
|
||||
|
||||
use quiz;
|
||||
use quiz_attempt;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,9 +36,9 @@ require_once($CFG->dirroot . '/mod/quiz/lib.php');
|
||||
* @copyright 2008 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
public function test_quiz_has_grades() {
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
$quiz->grade = '100.0000';
|
||||
$quiz->sumgrades = '100.0000';
|
||||
$this->assertTrue(quiz_has_grades($quiz));
|
||||
@@ -48,7 +51,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_quiz_format_grade() {
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
$quiz->decimalpoints = 2;
|
||||
$this->assertEquals(quiz_format_grade($quiz, 0.12345678), format_float(0.12, 2));
|
||||
$this->assertEquals(quiz_format_grade($quiz, 0), format_float(0, 2));
|
||||
@@ -58,7 +61,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_quiz_get_grade_format() {
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
$quiz->decimalpoints = 2;
|
||||
$this->assertEquals(quiz_get_grade_format($quiz), 2);
|
||||
$this->assertEquals($quiz->questiondecimalpoints, -1);
|
||||
@@ -72,7 +75,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_quiz_format_question_grade() {
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
$quiz->decimalpoints = 2;
|
||||
$quiz->questiondecimalpoints = 2;
|
||||
$this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.12, 2));
|
||||
@@ -173,7 +176,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
quiz_add_quiz_question($question->id, $quiz);
|
||||
|
||||
// Set grade to pass.
|
||||
$item = grade_item::fetch(['courseid' => $course->id, 'itemtype' => 'mod', 'itemmodule' => 'quiz',
|
||||
$item = \grade_item::fetch(['courseid' => $course->id, 'itemtype' => 'mod', 'itemmodule' => 'quiz',
|
||||
'iteminstance' => $quiz->id, 'outcomeid' => null]);
|
||||
$item->gradepass = 80;
|
||||
$item->update();
|
||||
@@ -196,7 +199,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$quizobj = quiz::create($attemptoptions['quiz']->id);
|
||||
|
||||
// Start the passing attempt.
|
||||
$quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
|
||||
|
||||
$timenow = time();
|
||||
@@ -457,15 +460,15 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$quizobj2a = quiz::create($quiz2->id, $u1->id);
|
||||
|
||||
// Set attempts.
|
||||
$quba1a = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1a->get_context());
|
||||
$quba1a = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1a->get_context());
|
||||
$quba1a->set_preferred_behaviour($quizobj1a->get_quiz()->preferredbehaviour);
|
||||
$quba1b = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1b->get_context());
|
||||
$quba1b = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1b->get_context());
|
||||
$quba1b->set_preferred_behaviour($quizobj1b->get_quiz()->preferredbehaviour);
|
||||
$quba1c = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1c->get_context());
|
||||
$quba1c = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1c->get_context());
|
||||
$quba1c->set_preferred_behaviour($quizobj1c->get_quiz()->preferredbehaviour);
|
||||
$quba1d = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1d->get_context());
|
||||
$quba1d = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj1d->get_context());
|
||||
$quba1d->set_preferred_behaviour($quizobj1d->get_quiz()->preferredbehaviour);
|
||||
$quba2a = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a->set_preferred_behaviour($quizobj2a->get_quiz()->preferredbehaviour);
|
||||
|
||||
$timenow = time();
|
||||
@@ -498,7 +501,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$attemptobj->process_abandon($timenow, true);
|
||||
|
||||
// User 1 attempts the quiz three times (abandon, finish, in progress).
|
||||
$quba2a = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a->set_preferred_behaviour($quizobj2a->get_quiz()->preferredbehaviour);
|
||||
|
||||
$attempt = quiz_create_attempt($quizobj2a, 1, false, $timenow, false, $u1->id);
|
||||
@@ -507,7 +510,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$attemptobj = quiz_attempt::create($attempt->id);
|
||||
$attemptobj->process_abandon($timenow, true);
|
||||
|
||||
$quba2a = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a->set_preferred_behaviour($quizobj2a->get_quiz()->preferredbehaviour);
|
||||
|
||||
$attempt = quiz_create_attempt($quizobj2a, 2, false, $timenow, false, $u1->id);
|
||||
@@ -516,7 +519,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$attemptobj = quiz_attempt::create($attempt->id);
|
||||
$attemptobj->process_finish($timenow, false);
|
||||
|
||||
$quba2a = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj2a->get_context());
|
||||
$quba2a->set_preferred_behaviour($quizobj2a->get_quiz()->preferredbehaviour);
|
||||
|
||||
$attempt = quiz_create_attempt($quizobj2a, 3, false, $timenow, false, $u1->id);
|
||||
@@ -881,7 +884,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id));
|
||||
|
||||
// Remove the permission to attempt or review the quiz for the student role.
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
assign_capability('mod/quiz:reviewmyattempts', CAP_PROHIBIT, $studentrole->id, $coursecontext);
|
||||
assign_capability('mod/quiz:attempt', CAP_PROHIBIT, $studentrole->id, $coursecontext);
|
||||
|
||||
@@ -918,7 +921,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id));
|
||||
|
||||
// Remove the permission to attempt or review the quiz for the student role.
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$coursecontext = \context_course::instance($course->id);
|
||||
assign_capability('mod/quiz:reviewmyattempts', CAP_PROHIBIT, $studentrole->id, $coursecontext);
|
||||
assign_capability('mod/quiz:attempt', CAP_PROHIBIT, $studentrole->id, $coursecontext);
|
||||
|
||||
@@ -965,7 +968,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
// Create an attempt for the student in the quiz.
|
||||
$timenow = time();
|
||||
$attempt = quiz_create_attempt($quizobj, 1, false, $timenow, false, $student->id);
|
||||
$quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
|
||||
quiz_start_new_attempt($quizobj, $quba, $attempt, 1, $timenow);
|
||||
quiz_attempt_save_started($quizobj, $quba, $attempt);
|
||||
@@ -1020,7 +1023,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
// Create an attempt for the student in the quiz.
|
||||
$timenow = time();
|
||||
$attempt = quiz_create_attempt($quizobj, 1, false, $timenow, false, $student->id);
|
||||
$quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
|
||||
$quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
|
||||
quiz_start_new_attempt($quizobj, $quba, $attempt, 1, $timenow);
|
||||
quiz_attempt_save_started($quizobj, $quba, $attempt);
|
||||
@@ -1057,7 +1060,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -1091,7 +1094,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -1113,7 +1116,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'quiz';
|
||||
$event->courseid = $courseid;
|
||||
@@ -1122,7 +1125,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1148,13 +1151,13 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionusegrade' => 0
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('quiz', $quiz1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('quiz', $quiz2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('quiz', $quiz1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('quiz', $quiz2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => [
|
||||
'completionattemptsexhausted' => 1,
|
||||
]];
|
||||
@@ -1166,7 +1169,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1175,7 +1178,7 @@ class mod_quiz_lib_testcase extends advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_quiz;
|
||||
|
||||
use quiz_attempt;
|
||||
use mod_quiz_display_options;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,10 +39,10 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
public function test_quiz_rescale_grade() {
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
$quiz->decimalpoints = 2;
|
||||
$quiz->questiondecimalpoints = 3;
|
||||
$quiz->grade = 10;
|
||||
@@ -82,7 +85,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
public function test_quiz_attempt_state($attemptstate,
|
||||
$relativetimefinish, $relativetimeclose, $expectedstate) {
|
||||
|
||||
$attempt = new stdClass();
|
||||
$attempt = new \stdClass();
|
||||
$attempt->state = $attemptstate;
|
||||
if ($relativetimefinish === null) {
|
||||
$attempt->timefinish = 0;
|
||||
@@ -90,7 +93,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$attempt->timefinish = time() + $relativetimefinish;
|
||||
}
|
||||
|
||||
$quiz = new stdClass();
|
||||
$quiz = new \stdClass();
|
||||
if ($relativetimeclose === null) {
|
||||
$quiz->timeclose = 0;
|
||||
} else {
|
||||
@@ -101,7 +104,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_quiz_question_tostring() {
|
||||
$question = new stdClass();
|
||||
$question = new \stdClass();
|
||||
$question->qtype = 'multichoice';
|
||||
$question->name = 'The question name';
|
||||
$question->questiontext = '<p>What sort of <b>inequality</b> is x < y<img alt="?" src="..."></p>';
|
||||
@@ -127,7 +130,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($quiz->cmid);
|
||||
$context = \context_module::instance($quiz->cmid);
|
||||
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -148,7 +151,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -354,16 +357,16 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
// Let's test quiz 1 closes in three hours for user student 1 since member of group 1.
|
||||
// Quiz 2 closes in two hours.
|
||||
$this->setUser($student1id);
|
||||
$params = new stdClass();
|
||||
$params = new \stdClass();
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz1->id;
|
||||
$object->usertimeclose = $basetimestamp + 10800; // The overriden timeclose for quiz 1.
|
||||
|
||||
$comparearray[$quiz1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz2->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The unchanged timeclose for quiz 2.
|
||||
|
||||
@@ -373,16 +376,16 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
|
||||
// Let's test quiz 1 closes in two hours (the original value) for user student 3 since member of no group.
|
||||
$this->setUser($student3id);
|
||||
$params = new stdClass();
|
||||
$params = new \stdClass();
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz1->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The original timeclose for quiz 1.
|
||||
|
||||
$comparearray[$quiz1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz2->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The original timeclose for quiz 2.
|
||||
|
||||
@@ -403,13 +406,13 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($student2id);
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz1->id;
|
||||
$object->usertimeclose = $basetimestamp + 14400; // The overriden timeclose for quiz 1.
|
||||
|
||||
$comparearray[$quiz1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz2->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The unchanged timeclose for quiz 2.
|
||||
|
||||
@@ -422,13 +425,13 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($teacherid);
|
||||
|
||||
$comparearray = array();
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz1->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The unchanged timeclose for quiz 1.
|
||||
|
||||
$comparearray[$quiz1->id] = $object;
|
||||
|
||||
$object = new stdClass();
|
||||
$object = new \stdClass();
|
||||
$object->id = $quiz2->id;
|
||||
$object->usertimeclose = $basetimestamp + 7200; // The unchanged timeclose for quiz 2.
|
||||
|
||||
@@ -542,7 +545,7 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
$slottags = quiz_retrieve_slot_tags($slotid);
|
||||
|
||||
// Now remove the foo tag and check again.
|
||||
core_tag_tag::delete_tags([$tags['foo']->id]);
|
||||
\core_tag_tag::delete_tags([$tags['foo']->id]);
|
||||
$slottags = quiz_retrieve_slot_tags($slotid);
|
||||
|
||||
$this->assertEqualsCanonicalizing(
|
||||
@@ -962,11 +965,11 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
|
||||
// Allow recipent to receive email confirm submission.
|
||||
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
||||
assign_capability('mod/quiz:emailconfirmsubmission', CAP_ALLOW, $studentrole->id,
|
||||
context_course::instance($course->id), true);
|
||||
\context_course::instance($course->id), true);
|
||||
$this->getDataGenerator()->enrol_user($recipient->id, $course->id, $studentrole->id, 'manual');
|
||||
|
||||
$timenow = time();
|
||||
$data = new stdClass();
|
||||
$data = new \stdClass();
|
||||
// Course info.
|
||||
$data->courseid = $course->id;
|
||||
$data->coursename = $course->fullname;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_resource;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_resource_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Prepares things before this test case is initialised
|
||||
@@ -62,7 +63,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$resource = $this->getDataGenerator()->create_module('resource', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($resource->cmid);
|
||||
$context = \context_module::instance($resource->cmid);
|
||||
$cm = get_coursemodule_from_instance('resource', $resource->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -84,7 +85,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -112,7 +113,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Create a resource with one file.
|
||||
$draftid = file_get_unused_draft_itemid();
|
||||
$contextid = context_user::instance($USER->id)->id;
|
||||
$contextid = \context_user::instance($USER->id)->id;
|
||||
$filerecord = array('component' => 'user', 'filearea' => 'draft', 'contextid' => $contextid,
|
||||
'itemid' => $draftid, 'filename' => 'r2.txt', 'filepath' => '/');
|
||||
$fs = get_file_storage();
|
||||
@@ -197,7 +198,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -234,7 +235,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -268,7 +269,7 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'resource';
|
||||
$event->courseid = $courseid;
|
||||
@@ -277,6 +278,6 @@ class mod_resource_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_scorm;
|
||||
|
||||
use mod_scorm_get_completion_active_rule_descriptions;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -40,7 +43,7 @@ require_once($CFG->dirroot . '/mod/scorm/lib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Set up for every test
|
||||
@@ -53,7 +56,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
// Setup test data.
|
||||
$this->course = $this->getDataGenerator()->create_course();
|
||||
$this->scorm = $this->getDataGenerator()->create_module('scorm', array('course' => $this->course->id));
|
||||
$this->context = context_module::instance($this->scorm->cmid);
|
||||
$this->context = \context_module::instance($this->scorm->cmid);
|
||||
$this->cm = get_coursemodule_from_instance('scorm', $this->scorm->id);
|
||||
|
||||
// Create users.
|
||||
@@ -88,7 +91,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals('on', $newattempt);
|
||||
|
||||
// Now do the same with a SCORM 2004 package.
|
||||
$record = new stdClass();
|
||||
$record = new \stdClass();
|
||||
$record->course = $this->course->id;
|
||||
$record->packagefilepath = $CFG->dirroot.'/mod/scorm/tests/packages/RuntimeBasicCalls_SCORM20043rdEdition.zip';
|
||||
$scorm13 = $this->getDataGenerator()->create_module('scorm', $record);
|
||||
@@ -426,7 +429,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -460,7 +463,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -483,7 +486,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype, $timestart = null) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'scorm';
|
||||
$event->courseid = $courseid;
|
||||
@@ -498,7 +501,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
$event->timestart = time();
|
||||
}
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,13 +529,13 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
'completionscorerequired' => null,
|
||||
'completionstatusallscos' => null
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('scorm', $scorm1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('scorm', $scorm2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('scorm', $scorm1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('scorm', $scorm2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => [
|
||||
'completionstatusrequired' => 6,
|
||||
'completionscorerequired' => 5,
|
||||
@@ -557,7 +560,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -862,7 +865,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
|
||||
public function test_creation_with_no_calendar_capabilities() {
|
||||
$this->resetAfterTest();
|
||||
$course = self::getDataGenerator()->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$context = \context_course::instance($course->id);
|
||||
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$roleid = self::getDataGenerator()->create_role();
|
||||
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_scorm;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -37,7 +38,7 @@ require_once($CFG->dirroot . '/mod/scorm/lib.php');
|
||||
* @copyright 2017 Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_scorm_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
namespace mod_survey;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.0
|
||||
*/
|
||||
class mod_survey_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Prepares things before this test case is initialised
|
||||
@@ -62,7 +63,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$survey = $this->getDataGenerator()->create_module('survey', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($survey->cmid);
|
||||
$context = \context_module::instance($survey->cmid);
|
||||
$cm = get_coursemodule_from_instance('survey', $survey->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -84,7 +85,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -123,7 +124,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
// Setup test data.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$survey = $this->getDataGenerator()->create_module('survey', array('course' => $course->id));
|
||||
$context = context_module::instance($survey->cmid);
|
||||
$context = \context_module::instance($survey->cmid);
|
||||
|
||||
// Build our questions and responses array.
|
||||
$realquestions = array();
|
||||
@@ -277,7 +278,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -315,7 +316,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the $student1.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student1->id);
|
||||
|
||||
// Now log in as $student2.
|
||||
@@ -340,7 +341,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'survey';
|
||||
$event->courseid = $courseid;
|
||||
@@ -349,7 +350,7 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,13 +374,13 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
'completion' => 2,
|
||||
'completionsubmit' => 0,
|
||||
]);
|
||||
$cm1 = cm_info::create(get_coursemodule_from_instance('survey', $survey1->id));
|
||||
$cm2 = cm_info::create(get_coursemodule_from_instance('survey', $survey2->id));
|
||||
$cm1 = \cm_info::create(get_coursemodule_from_instance('survey', $survey1->id));
|
||||
$cm2 = \cm_info::create(get_coursemodule_from_instance('survey', $survey2->id));
|
||||
|
||||
// Data for the stdClass input type.
|
||||
// This type of input would occur when checking the default completion rules for an activity type, where we don't have
|
||||
// any access to cm_info, rather the input is a stdClass containing completion and customdata attributes, just like cm_info.
|
||||
$moddefaults = new stdClass();
|
||||
$moddefaults = new \stdClass();
|
||||
$moddefaults->customdata = ['customcompletionrules' => ['completionsubmit' => 1]];
|
||||
$moddefaults->completion = 2;
|
||||
|
||||
@@ -387,6 +388,6 @@ class mod_survey_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(mod_survey_get_completion_active_rule_descriptions($cm1), $activeruledescriptions);
|
||||
$this->assertEquals(mod_survey_get_completion_active_rule_descriptions($cm2), []);
|
||||
$this->assertEquals(mod_survey_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
|
||||
$this->assertEquals(mod_survey_get_completion_active_rule_descriptions(new stdClass()), []);
|
||||
$this->assertEquals(mod_survey_get_completion_active_rule_descriptions(new \stdClass()), []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_url_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Prepares things before this test case is initialised
|
||||
@@ -107,7 +108,7 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
|
||||
$url = $this->getDataGenerator()->create_module('url', array('course' => $course->id),
|
||||
array('completion' => 2, 'completionview' => 1));
|
||||
$context = context_module::instance($url->cmid);
|
||||
$context = \context_module::instance($url->cmid);
|
||||
$cm = get_coursemodule_from_instance('url', $url->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -130,7 +131,7 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
@@ -159,7 +160,7 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -231,7 +232,7 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -253,7 +254,7 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'url';
|
||||
$event->courseid = $courseid;
|
||||
@@ -262,6 +263,6 @@ class mod_url_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-19
@@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
namespace mod_wiki;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -40,7 +41,7 @@ require_once($CFG->libdir . '/completionlib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test wiki_view.
|
||||
@@ -58,7 +59,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => COMPLETION_ENABLED));
|
||||
$options = array('completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => COMPLETION_VIEW_REQUIRED);
|
||||
$wiki = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id), $options);
|
||||
$context = context_module::instance($wiki->cmid);
|
||||
$context = \context_module::instance($wiki->cmid);
|
||||
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
|
||||
|
||||
// Trigger and capture the event.
|
||||
@@ -80,7 +81,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -102,7 +103,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$course = $this->getDataGenerator()->create_course(array('enablecompletion' => COMPLETION_ENABLED));
|
||||
$options = array('completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => COMPLETION_VIEW_REQUIRED);
|
||||
$wiki = $this->getDataGenerator()->create_module('wiki', array('course' => $course->id), $options);
|
||||
$context = context_module::instance($wiki->cmid);
|
||||
$context = \context_module::instance($wiki->cmid);
|
||||
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
|
||||
$firstpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_first_page($wiki);
|
||||
|
||||
@@ -125,7 +126,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$this->assertNotEmpty($event->get_name());
|
||||
|
||||
// Check completion status.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completiondata = $completion->get_data($cm);
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
|
||||
@@ -158,7 +159,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id, 'manual');
|
||||
|
||||
// Simulate collaborative subwiki.
|
||||
$swcol = new stdClass();
|
||||
$swcol = new \stdClass();
|
||||
$swcol->id = -1;
|
||||
$swcol->wikiid = $colwiki->id;
|
||||
$swcol->groupid = 0;
|
||||
@@ -236,7 +237,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate all the possible subwikis.
|
||||
// Subwikis in collaborative wikis: 1 subwiki per group + 1 subwiki for all participants.
|
||||
$swsepcolg1 = new stdClass();
|
||||
$swsepcolg1 = new \stdClass();
|
||||
$swsepcolg1->id = -1;
|
||||
$swsepcolg1->wikiid = $wikisepcol->id;
|
||||
$swsepcolg1->groupid = $group1->id;
|
||||
@@ -331,7 +332,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Simulate all the possible subwikis.
|
||||
// Subwikis in collaborative wikis: 1 subwiki per group + 1 subwiki for all participants.
|
||||
$swsepindg1s1 = new stdClass();
|
||||
$swsepindg1s1 = new \stdClass();
|
||||
$swsepindg1s1->id = -1;
|
||||
$swsepindg1s1->wikiid = $wikisepind->id;
|
||||
$swsepindg1s1->groupid = $group1->id;
|
||||
@@ -427,7 +428,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check that the student can get the only subwiki from the collaborative wiki.
|
||||
$expectedsubwikis = array();
|
||||
$expectedsubwiki = new stdClass();
|
||||
$expectedsubwiki = new \stdClass();
|
||||
$expectedsubwiki->id = -1; // We haven't created any page so the subwiki hasn't been created.
|
||||
$expectedsubwiki->wikiid = $colwiki->id;
|
||||
$expectedsubwiki->groupid = 0;
|
||||
@@ -460,7 +461,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check that the teacher can see his subwiki and the student subwiki in the individual wiki.
|
||||
$this->setUser($teacher);
|
||||
$teachersubwiki = new stdClass();
|
||||
$teachersubwiki = new \stdClass();
|
||||
$teachersubwiki->id = -1;
|
||||
$teachersubwiki->wikiid = $indwiki->id;
|
||||
$teachersubwiki->groupid = 0;
|
||||
@@ -515,7 +516,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Create all the possible subwikis. We haven't created any page so ids will be -1.
|
||||
// Subwikis in collaborative wikis: 1 subwiki per group + 1 subwiki for all participants.
|
||||
$swsepcolg1 = new stdClass();
|
||||
$swsepcolg1 = new \stdClass();
|
||||
$swsepcolg1->id = -1;
|
||||
$swsepcolg1->wikiid = $wikisepcol->id;
|
||||
$swsepcolg1->groupid = $group1->id;
|
||||
@@ -599,7 +600,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Create all the possible subwikis to be returned. We haven't created any page so ids will be -1.
|
||||
// Subwikis in individual wikis: 1 subwiki per user and group. If user doesn't belong to any group then groupid is 0.
|
||||
$swsepindg1s1 = new stdClass();
|
||||
$swsepindg1s1 = new \stdClass();
|
||||
$swsepindg1s1->id = -1;
|
||||
$swsepindg1s1->wikiid = $wikisepind->id;
|
||||
$swsepindg1s1->groupid = $group1->id;
|
||||
@@ -679,7 +680,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$page23 = $wikigenerator->create_content($wiki2, array('tags' => array('mice', 'Cats')));
|
||||
$page31 = $wikigenerator->create_content($wiki3, array('tags' => array('mice', 'Cats')));
|
||||
|
||||
$tag = core_tag_tag::get_by_name(0, 'Cats');
|
||||
$tag = \core_tag_tag::get_by_name(0, 'Cats');
|
||||
|
||||
// Admin can see everything.
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
@@ -715,7 +716,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course1->id, $studentrole->id, 'manual');
|
||||
$this->getDataGenerator()->enrol_user($student->id, $course2->id, $studentrole->id, 'manual');
|
||||
$this->setUser($student);
|
||||
core_tag_index_builder::reset_caches();
|
||||
\core_tag_index_builder::reset_caches();
|
||||
|
||||
// User can not see pages in course 3 because he is not enrolled.
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
@@ -725,7 +726,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page31->title.'/', $res->content);
|
||||
|
||||
// User can search wiki pages inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$coursecontext = \context_course::instance($course1->id);
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$page = */0);
|
||||
$this->assertMatchesRegularExpression('/'.$page11->title.'/', $res->content);
|
||||
@@ -847,7 +848,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -885,7 +886,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the $student1.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student1->id);
|
||||
|
||||
// Now log in as $student2.
|
||||
@@ -910,7 +911,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'wiki';
|
||||
$event->courseid = $courseid;
|
||||
@@ -919,6 +920,6 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
* Unit tests for grading evaluation method "best"
|
||||
*
|
||||
* @package workshopeval_best
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2009 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace workshopeval_best;
|
||||
|
||||
use workshop;
|
||||
use workshop_best_evaluation;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,8 +35,10 @@ require_once($CFG->dirroot . '/mod/workshop/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/workshop/eval/best/lib.php');
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
|
||||
class workshopeval_best_evaluation_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Unit tests for grading evaluation lib.php
|
||||
*/
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/** workshop instance emulation */
|
||||
protected $workshop;
|
||||
@@ -332,7 +338,7 @@ class testable_workshop_best_evaluation extends workshop_best_evaluation {
|
||||
public function weighted_variance(array $assessments) {
|
||||
return parent::weighted_variance($assessments);
|
||||
}
|
||||
public function assessments_distance(stdclass $assessment, stdclass $referential, array $diminfo, stdclass $settings) {
|
||||
public function assessments_distance(\stdClass $assessment, \stdClass $referential, array $diminfo, \stdClass $settings) {
|
||||
return parent::assessments_distance($assessment, $referential, $diminfo, $settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
* Unit tests for Accumulative grading strategy logic
|
||||
*
|
||||
* @package workshopform_accumulative
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2009 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace workshopform_accumulative;
|
||||
|
||||
use workshop;
|
||||
use workshop_accumulative_strategy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -30,8 +34,10 @@ global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/workshop/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/workshop/form/accumulative/lib.php');
|
||||
|
||||
|
||||
class workshop_accumulative_strategy_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Unit tests for Accumulative grading strategy lib.php
|
||||
*/
|
||||
class lib_test extends \advanced_testcase {
|
||||
/** workshop instance emulation */
|
||||
protected $workshop;
|
||||
|
||||
@@ -83,7 +89,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase {
|
||||
$this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '-1');
|
||||
$grades[] = (object)array('dimensionid' => 1003, 'grade' => '20');
|
||||
// exercise SUT
|
||||
$this->expectException(coding_exception::class);
|
||||
$this->expectException(\coding_exception::class);
|
||||
$suggested = $this->strategy->calculate_peer_grade($grades);
|
||||
}
|
||||
|
||||
@@ -184,7 +190,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase {
|
||||
$grades[] = (object)array('dimensionid' => 1012, 'grade' => '4.00000'); // exceeds the number of scale items
|
||||
|
||||
// Exercise SUT.
|
||||
$this->expectException(coding_exception::class);
|
||||
$this->expectException(\coding_exception::class);
|
||||
$suggested = $this->strategy->calculate_peer_grade($grades);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -19,10 +18,14 @@
|
||||
* Unit tests for Number of errors grading logic
|
||||
*
|
||||
* @package workshopform_numerrors
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2009 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace workshopform_numerrors;
|
||||
|
||||
use workshop;
|
||||
use workshop_numerrors_strategy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,8 +34,10 @@ global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/workshop/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/workshop/form/numerrors/lib.php');
|
||||
|
||||
|
||||
class workshopform_numerrors_strategy_testcase extends advanced_testcase {
|
||||
/**
|
||||
* Unit tests for Number of errors grading lib.php
|
||||
*/
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/** workshop instance emulation */
|
||||
protected $workshop;
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
* Unit tests for Rubric grading strategy logic
|
||||
*
|
||||
* @package workshopform_rubric
|
||||
* @category phpunit
|
||||
* @category test
|
||||
* @copyright 2009 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace workshopform_rubric;
|
||||
|
||||
use workshop;
|
||||
use workshop_rubric_strategy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -30,8 +34,10 @@ global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/workshop/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/workshop/form/rubric/lib.php');
|
||||
|
||||
|
||||
class workshopform_rubric_strategy_test extends advanced_testcase {
|
||||
/**
|
||||
* Unit tests for Rubric grading strategy lib.php
|
||||
*/
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/** workshop instance emulation */
|
||||
protected $workshop;
|
||||
@@ -53,7 +59,7 @@ class workshopform_rubric_strategy_test extends advanced_testcase {
|
||||
$this->strategy = new testable_workshop_rubric_strategy($this->workshop);
|
||||
|
||||
// prepare dimensions definition
|
||||
$dim = new stdclass();
|
||||
$dim = new \stdClass();
|
||||
$dim->id = 6;
|
||||
$dim->levels[10] = (object)array('id' => 10, 'grade' => 0);
|
||||
$dim->levels[13] = (object)array('id' => 13, 'grade' => 2);
|
||||
@@ -61,7 +67,7 @@ class workshopform_rubric_strategy_test extends advanced_testcase {
|
||||
$dim->levels[16] = (object)array('id' => 16, 'grade' => 8);
|
||||
$this->strategy->dimensions[$dim->id] = $dim;
|
||||
|
||||
$dim = new stdclass();
|
||||
$dim = new \stdClass();
|
||||
$dim->id = 8;
|
||||
$dim->levels[17] = (object)array('id' => 17, 'grade' => 0);
|
||||
$dim->levels[18] = (object)array('id' => 18, 'grade' => 1);
|
||||
@@ -69,7 +75,7 @@ class workshopform_rubric_strategy_test extends advanced_testcase {
|
||||
$dim->levels[20] = (object)array('id' => 20, 'grade' => 3);
|
||||
$this->strategy->dimensions[$dim->id] = $dim;
|
||||
|
||||
$dim = new stdclass();
|
||||
$dim = new \stdClass();
|
||||
$dim->id = 10;
|
||||
$dim->levels[27] = (object)array('id' => 27, 'grade' => 10);
|
||||
$dim->levels[28] = (object)array('id' => 28, 'grade' => 20);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* @copyright 2017 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_workshop;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
@@ -31,7 +33,7 @@ require_once($CFG->dirroot . '/mod/workshop/lib.php');
|
||||
* @copyright 2017 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test calendar event provide action open.
|
||||
@@ -327,7 +329,7 @@ class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -361,7 +363,7 @@ class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
|
||||
|
||||
// Mark the activity as completed for the student.
|
||||
$completion = new completion_info($course);
|
||||
$completion = new \completion_info($course);
|
||||
$completion->set_module_viewed($cm, $student->id);
|
||||
|
||||
// Create an action factory.
|
||||
@@ -383,7 +385,7 @@ class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
* @return bool|calendar_event
|
||||
*/
|
||||
private function create_action_event($courseid, $instanceid, $eventtype) {
|
||||
$event = new stdClass();
|
||||
$event = new \stdClass();
|
||||
$event->name = 'Calendar event';
|
||||
$event->modulename = 'workshop';
|
||||
$event->courseid = $courseid;
|
||||
@@ -392,7 +394,7 @@ class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
$event->eventtype = $eventtype;
|
||||
$event->timestart = time();
|
||||
|
||||
return calendar_event::create($event);
|
||||
return \calendar_event::create($event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,8 +425,8 @@ class mod_workshop_lib_testcase extends advanced_testcase {
|
||||
);
|
||||
$workshop = $this->getDataGenerator()->create_module('workshop', $record);
|
||||
$cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$cm = cm_info::create($cm);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$cm = \cm_info::create($cm);
|
||||
|
||||
$this->setUser($student);
|
||||
// Check that upon creation, the updates are only about the new configuration created.
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
* @copyright 2009 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace mod_workshop;
|
||||
|
||||
use testable_workshop;
|
||||
use workshop;
|
||||
use workshop_example_assessment;
|
||||
use workshop_example_reference_assessment;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +39,7 @@ require_once(__DIR__ . '/fixtures/testable.php');
|
||||
/**
|
||||
* Test cases for the internal workshop api
|
||||
*/
|
||||
class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
/** @var object */
|
||||
protected $course;
|
||||
@@ -195,7 +201,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
$batch[] = (object)array('reviewerid'=>3, 'gradinggrade'=>82.87670, 'gradinggradeover'=>null, 'aggregationid'=>null, 'aggregatedgrade'=>null);
|
||||
// expectation
|
||||
$now = time();
|
||||
$expected = new stdclass();
|
||||
$expected = new \stdClass();
|
||||
$expected->workshopid = $this->workshop->id;
|
||||
$expected->userid = 3;
|
||||
$expected->gradinggrade = 82.87670;
|
||||
@@ -247,7 +253,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
$batch[] = (object)array('reviewerid'=>5, 'gradinggrade'=>51.12000, 'gradinggradeover'=>null, 'aggregationid'=>null, 'aggregatedgrade'=>null);
|
||||
// expectation
|
||||
$now = time();
|
||||
$expected = new stdclass();
|
||||
$expected = new \stdClass();
|
||||
$expected->workshopid = $this->workshop->id;
|
||||
$expected->userid = 5;
|
||||
$expected->gradinggrade = 79.3066;
|
||||
@@ -327,7 +333,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
$percent = -7.098;
|
||||
|
||||
// exercise SUT
|
||||
$this->expectException(coding_exception::class);
|
||||
$this->expectException(\coding_exception::class);
|
||||
$part = workshop::percent_to_value($percent, $total);
|
||||
}
|
||||
|
||||
@@ -338,7 +344,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
$percent = 121.08;
|
||||
|
||||
// exercise SUT
|
||||
$this->expectException(coding_exception::class);
|
||||
$this->expectException(\coding_exception::class);
|
||||
$part = workshop::percent_to_value($percent, $total);
|
||||
}
|
||||
|
||||
@@ -382,7 +388,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
$a = $this->workshop->prepare_example_assessment($fakerawrecord);
|
||||
// verify
|
||||
$this->assertTrue($a instanceof workshop_example_assessment);
|
||||
$this->assertTrue($a->url instanceof moodle_url);
|
||||
$this->assertTrue($a->url instanceof \moodle_url);
|
||||
|
||||
// modify setup
|
||||
$fakerawrecord->weight = 1;
|
||||
@@ -462,7 +468,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
|
||||
|
||||
// The existing workshop doesn't have any restrictions, so user lists
|
||||
// should include all three users.
|
||||
$allusers = get_enrolled_users(context_course::instance($courseid));
|
||||
$allusers = get_enrolled_users(\context_course::instance($courseid));
|
||||
$result = $this->workshop->get_grouped($allusers);
|
||||
$this->assertCount(4, $result);
|
||||
$users = array_keys($result[0]);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2015 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace core_notes;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +34,7 @@ require_once($CFG->dirroot . '/notes/lib.php');
|
||||
* @copyright 2015 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class core_notes_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -72,7 +73,7 @@ class core_notes_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
core_notes_myprofile_navigation($this->tree, $USER, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('notes', $nodes->getValue($this->tree));
|
||||
@@ -89,7 +90,7 @@ class core_notes_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
core_notes_myprofile_navigation($this->tree, $USER, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('notes', $nodes->getValue($this->tree));
|
||||
@@ -109,7 +110,7 @@ class core_notes_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
core_notes_myprofile_navigation($this->tree, $USER, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('notes', $nodes->getValue($this->tree));
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace qbank_comment;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
@@ -28,7 +30,7 @@ require_once($CFG->dirroot . '/question/bank/comment/lib.php');
|
||||
* @author Matt Porritt <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qbank_comment_lib_test extends \advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test the comment validation callback.
|
||||
@@ -82,7 +84,7 @@ class qbank_comment_lib_test extends \advanced_testcase {
|
||||
$category = $this->getDataGenerator()->create_category();
|
||||
$course = $this->getDataGenerator()->create_course(['category' => $category->id]);
|
||||
$qgen = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$context = context_coursecat::instance($category->id);
|
||||
$context = \context_coursecat::instance($category->id);
|
||||
$qcat = $qgen->create_question_category(['contextid' => $context->id]);
|
||||
$question = $qgen->create_question('shortanswer', null, ['category' => $qcat->id, 'idnumber' => 'q1']);
|
||||
|
||||
@@ -110,7 +112,7 @@ class qbank_comment_lib_test extends \advanced_testcase {
|
||||
$category = $this->getDataGenerator()->create_category();
|
||||
$course = $this->getDataGenerator()->create_course(['category' => $category->id]);
|
||||
$qgen = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$context = context_coursecat::instance($category->id);
|
||||
$context = \context_coursecat::instance($category->id);
|
||||
$qcat = $qgen->create_question_category(['contextid' => $context->id]);
|
||||
$question = $qgen->create_question('shortanswer', null, ['category' => $qcat->id, 'idnumber' => 'q1']);
|
||||
$args = [
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_log;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +34,7 @@ global $CFG;
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_log_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -89,7 +90,7 @@ class report_log_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
report_log_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('alllogs', $nodes->getValue($this->tree));
|
||||
@@ -106,7 +107,7 @@ class report_log_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Check the node tree is correct.
|
||||
report_log_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('alllogs', $nodes->getValue($this->tree));
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_loglive;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_loglive_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test report_log_supports_logstore.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_outline;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -33,7 +34,7 @@ global $CFG;
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_outline_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -65,7 +66,7 @@ class report_outline_lib_testcase extends advanced_testcase {
|
||||
$this->user2 = $this->getDataGenerator()->create_user();
|
||||
$this->course = $this->getDataGenerator()->create_course();
|
||||
$this->tree = new \core_user\output\myprofile\tree();
|
||||
$this->coursecontext = context_course::instance($this->course->id);
|
||||
$this->coursecontext = \context_course::instance($this->course->id);
|
||||
$this->roleid = create_role('Dummy role', 'dummyrole', 'dummy role description');
|
||||
$this->resetAfterTest();
|
||||
}
|
||||
@@ -99,7 +100,7 @@ class report_outline_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = false;
|
||||
|
||||
report_outline_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('outline', $nodes->getValue($this->tree));
|
||||
@@ -114,7 +115,7 @@ class report_outline_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = true;
|
||||
|
||||
report_outline_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('outline', $nodes->getValue($this->tree));
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_participation;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_participation_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test report_log_supports_logstore.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_stats;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_stats_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -87,7 +88,7 @@ class report_stats_lib_testcase extends advanced_testcase {
|
||||
set_config('enablestats', true);
|
||||
|
||||
report_stats_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('stats', $nodes->getValue($this->tree));
|
||||
@@ -104,7 +105,7 @@ class report_stats_lib_testcase extends advanced_testcase {
|
||||
set_config('enablestats', false);
|
||||
|
||||
report_stats_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('stats', $nodes->getValue($this->tree));
|
||||
@@ -122,7 +123,7 @@ class report_stats_lib_testcase extends advanced_testcase {
|
||||
set_config('enablestats', true);
|
||||
|
||||
report_stats_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('stats', $nodes->getValue($this->tree));
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2015 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_usersessions;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -35,7 +36,7 @@ require_once($CFG->dirroot. '/report/usersessions/lib.php');
|
||||
* @copyright 2014 onwards Ankit agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_usersessions_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* @var stdClass The user.
|
||||
@@ -68,7 +69,7 @@ class report_usersessions_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Not even admins allowed to pick at other user's sessions.
|
||||
report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree));
|
||||
@@ -82,7 +83,7 @@ class report_usersessions_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = true;
|
||||
|
||||
report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayHasKey('usersessions', $nodes->getValue($this->tree));
|
||||
@@ -96,7 +97,7 @@ class report_usersessions_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = true;
|
||||
|
||||
report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree));
|
||||
@@ -112,7 +113,7 @@ class report_usersessions_lib_testcase extends advanced_testcase {
|
||||
$iscurrentuser = false;
|
||||
|
||||
report_usersessions_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course);
|
||||
$reflector = new ReflectionObject($this->tree);
|
||||
$reflector = new \ReflectionObject($this->tree);
|
||||
$nodes = $reflector->getProperty('nodes');
|
||||
$nodes->setAccessible(true);
|
||||
$this->assertArrayNotHasKey('usersessions', $nodes->getValue($this->tree));
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
* @copyright 2017 Project seminar (Learnweb, University of Münster)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace repository_nextcloud;
|
||||
|
||||
use repository;
|
||||
use repository_nextcloud;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -34,7 +38,7 @@ require_once($CFG->libdir . '/webdavlib.php');
|
||||
* @copyright 2017 Project seminar (Learnweb, University of Münster)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_nextcloud_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/** @var null|\repository_nextcloud the repository_nextcloud object, which the tests are run on. */
|
||||
private $repo = null;
|
||||
@@ -505,7 +509,7 @@ JSON;
|
||||
|
||||
$this->assertEquals($this->repo->print_login(), $this->repo->logout());
|
||||
|
||||
$mock->expects($this->exactly(2))->method('get_login_url')->will($this->returnValue(new moodle_url('url')));
|
||||
$mock->expects($this->exactly(2))->method('get_login_url')->will($this->returnValue(new \moodle_url('url')));
|
||||
|
||||
$this->repo->options['ajax'] = true;
|
||||
$this->assertEquals($this->repo->print_login(), $this->repo->logout());
|
||||
@@ -561,13 +565,13 @@ JSON;
|
||||
*/
|
||||
public function test_print_login() {
|
||||
$mock = $this->createMock(\core\oauth2\client::class);
|
||||
$mock->expects($this->exactly(2))->method('get_login_url')->will($this->returnValue(new moodle_url('url')));
|
||||
$mock->expects($this->exactly(2))->method('get_login_url')->will($this->returnValue(new \moodle_url('url')));
|
||||
$this->set_private_property($mock, 'client');
|
||||
|
||||
// Test with ajax activated.
|
||||
$this->repo->options['ajax'] = true;
|
||||
|
||||
$url = new moodle_url('url');
|
||||
$url = new \moodle_url('url');
|
||||
$ret = array();
|
||||
$btn = new \stdClass();
|
||||
$btn->type = 'popup';
|
||||
@@ -579,7 +583,7 @@ JSON;
|
||||
// Test without ajax.
|
||||
$this->repo->options['ajax'] = false;
|
||||
|
||||
$output = html_writer::link($url, get_string('login', 'repository'),
|
||||
$output = \html_writer::link($url, get_string('login', 'repository'),
|
||||
array('target' => '_blank', 'rel' => 'noopener noreferrer'));
|
||||
$this->expectOutputString($output);
|
||||
$this->repo->print_login();
|
||||
@@ -602,16 +606,16 @@ JSON;
|
||||
$generator->test_create_single_endpoint($this->issuer->get('id'), "webdav_endpoint",
|
||||
"https://www.default.test:8080/webdav/index.php");
|
||||
|
||||
$fakeaccesstoken = new stdClass();
|
||||
$fakeaccesstoken = new \stdClass();
|
||||
$fakeaccesstoken->token = "fake access token";
|
||||
$oauthmock = $this->createMock(\core\oauth2\client::class);
|
||||
$oauthmock->expects($this->once())->method('get_accesstoken')->will($this->returnValue($fakeaccesstoken));
|
||||
$this->set_private_property($oauthmock, 'client');
|
||||
|
||||
$dav = phpunit_util::call_internal_method($this->repo, "initiate_webdavclient", [], 'repository_nextcloud');
|
||||
$dav = \phpunit_util::call_internal_method($this->repo, "initiate_webdavclient", [], 'repository_nextcloud');
|
||||
|
||||
// Verify that port is set correctly (private property).
|
||||
$refclient = new ReflectionClass($dav);
|
||||
$refclient = new \ReflectionClass($dav);
|
||||
|
||||
$property = $refclient->getProperty('_port');
|
||||
$property->setAccessible(true);
|
||||
@@ -629,7 +633,7 @@ JSON;
|
||||
public function test_supported_returntypes() {
|
||||
global $DB;
|
||||
$this->assertEquals(FILE_INTERNAL | FILE_REFERENCE, $this->repo->supported_returntypes());
|
||||
$dataobject = new stdClass();
|
||||
$dataobject = new \stdClass();
|
||||
$dataobject->timecreated = time();
|
||||
$dataobject->timemodified = time();
|
||||
$dataobject->usermodified = 2;
|
||||
@@ -654,36 +658,36 @@ JSON;
|
||||
public function test_reference_file_selected_error() {
|
||||
$this->repo->disabled = true;
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->disabled = false;
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('Cannot connect as system user');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$mock = $this->createMock(\core\oauth2\client::class);
|
||||
$mock->expects($this->once())->method('get_system_oauth_client')->with($this->issuer)->willReturn(true);
|
||||
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('Cannot connect as current user');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->expects($this->once())->method('get_user_oauth_client')->willReturn(true);
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('cannotdownload');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->expects($this->once())->method('get_user_oauth_client')->willReturn(true);
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('cannotdownload');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->expects($this->once())->method('get_user_oauth_client')->willReturn(true);
|
||||
$this->repo->expects($this->once())->method('copy_file_to_path')->willReturn(array('statuscode' =>
|
||||
array('success' => 400)));
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('Could not copy file');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->expects($this->once())->method('get_user_oauth_client')->willReturn(true);
|
||||
$this->repo->expects($this->once())->method('copy_file_to_path')->willReturn(array('statuscode' =>
|
||||
@@ -692,7 +696,7 @@ JSON;
|
||||
array('statuscode' => array('success' => 400)));
|
||||
$this->expectException(\repository_exception::class);
|
||||
$this->expectExceptionMessage('Share is still present');
|
||||
$this->repo->reference_file_selected('', context_system::instance(), '', '', '');
|
||||
$this->repo->reference_file_selected('', \context_system::instance(), '', '', '');
|
||||
|
||||
$this->repo->expects($this->once())->method('get_user_oauth_client')->willReturn(true);
|
||||
$this->repo->expects($this->once())->method('copy_file_to_path')->willReturn(array('statuscode' =>
|
||||
@@ -704,7 +708,7 @@ JSON;
|
||||
$filereturn->name = 'mysource';
|
||||
$filereturn->usesystem = true;
|
||||
$filereturn = json_encode($filereturn);
|
||||
$return = $this->repo->reference_file_selected('mysource', context_system::instance(), '', '', '');
|
||||
$return = $this->repo->reference_file_selected('mysource', \context_system::instance(), '', '', '');
|
||||
$this->assertEquals($filereturn, $return);
|
||||
}
|
||||
|
||||
@@ -714,7 +718,7 @@ JSON;
|
||||
public function test_send_file_errors() {
|
||||
$fs = get_file_storage();
|
||||
$storedfile = $fs->create_file_from_reference([
|
||||
'contextid' => context_system::instance()->id,
|
||||
'contextid' => \context_system::instance()->id,
|
||||
'component' => 'core',
|
||||
'filearea' => 'unittest',
|
||||
'itemid' => 0,
|
||||
@@ -854,7 +858,7 @@ XML;
|
||||
'referecncelastsync done recently' => [
|
||||
[
|
||||
'storedfile_record' => [
|
||||
'contextid' => context_system::instance()->id,
|
||||
'contextid' => \context_system::instance()->id,
|
||||
'component' => 'core',
|
||||
'filearea' => 'unittest',
|
||||
'itemid' => 0,
|
||||
@@ -876,7 +880,7 @@ XML;
|
||||
'file without link' => [
|
||||
[
|
||||
'storedfile_record' => [
|
||||
'contextid' => context_system::instance()->id,
|
||||
'contextid' => \context_system::instance()->id,
|
||||
'component' => 'core',
|
||||
'filearea' => 'unittest',
|
||||
'itemid' => 0,
|
||||
@@ -896,7 +900,7 @@ XML;
|
||||
'file extenstion to exclude' => [
|
||||
[
|
||||
'storedfile_record' => [
|
||||
'contextid' => context_system::instance()->id,
|
||||
'contextid' => \context_system::instance()->id,
|
||||
'component' => 'core',
|
||||
'filearea' => 'unittest',
|
||||
'itemid' => 0,
|
||||
@@ -917,7 +921,7 @@ XML;
|
||||
'file extenstion for image' => [
|
||||
[
|
||||
'storedfile_record' => [
|
||||
'contextid' => context_system::instance()->id,
|
||||
'contextid' => \context_system::instance()->id,
|
||||
'component' => 'core',
|
||||
'filearea' => 'unittest',
|
||||
'itemid' => 0,
|
||||
@@ -952,7 +956,7 @@ XML;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
if (isset($storedfilemethodsmock[0])) {
|
||||
$storedfile = $this->createMock(stored_file::class);
|
||||
$storedfile = $this->createMock(\stored_file::class);
|
||||
|
||||
if ($storedfilemethodsmock[0] === 'get_referencelastsync') {
|
||||
if (!$expectedresult) {
|
||||
@@ -968,7 +972,7 @@ XML;
|
||||
|
||||
if ((isset($storedfileargs['mock_curl']) && $storedfileargs)) {
|
||||
// Lets mock curl, else it would not serve the purpose here.
|
||||
$curl = $this->createMock(curl::class);
|
||||
$curl = $this->createMock(\curl::class);
|
||||
$curl->method('download_one')->willReturn(true);
|
||||
$curl->method('get_info')->willReturn(['http_code' => 200]);
|
||||
|
||||
@@ -996,7 +1000,7 @@ XML;
|
||||
* @return ReflectionProperty the resulting reflection property.
|
||||
*/
|
||||
protected function set_private_property($value, $propertyname) {
|
||||
$refclient = new ReflectionClass($this->repo);
|
||||
$refclient = new \ReflectionClass($this->repo);
|
||||
$private = $refclient->getProperty($propertyname);
|
||||
$private->setAccessible(true);
|
||||
$private->setValue($this->repo, $value);
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
* @copyright Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace repository_recent;
|
||||
|
||||
use repository;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -38,7 +41,7 @@ require_once($CFG->dirroot . '/files/externallib.php');
|
||||
* @copyright Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_recent_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/** @var repository Recent repository */
|
||||
private $repo;
|
||||
@@ -52,7 +55,7 @@ class repository_recent_lib_testcase extends advanced_testcase {
|
||||
protected function setUp(): void {
|
||||
global $USER;
|
||||
$this->setAdminUser();
|
||||
$this->usercontext = context_user::instance($USER->id);
|
||||
$this->usercontext = \context_user::instance($USER->id);
|
||||
$repoid = $this->getDataGenerator()->create_repository('recent')->id;
|
||||
$this->repo = repository::get_repository_by_id($repoid, $this->usercontext);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* @copyright 2014 John Okely
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace repository_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
@@ -34,7 +35,7 @@ require_once($CFG->dirroot . '/repository/url/lib.php');
|
||||
* @copyright 2014 John Okely
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_url_lib_testcase extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Check that the url escaper performs as expected
|
||||
@@ -59,7 +60,7 @@ class repository_url_lib_testcase extends advanced_testcase {
|
||||
foreach ($conversions as $input => $expected) {
|
||||
// The constructor uses a optional_param, so we need to hack $_GET.
|
||||
$_GET['file'] = $input;
|
||||
$repository = new repository_url($repoid);
|
||||
$repository = new \repository_url($repoid);
|
||||
$this->assertSame($expected, $repository->file_url);
|
||||
}
|
||||
|
||||
@@ -75,9 +76,9 @@ class repository_url_lib_testcase extends advanced_testcase {
|
||||
try {
|
||||
// The constructor uses a optional_param, so we need to hack $_GET.
|
||||
$_GET['file'] = $input;
|
||||
$repository = new repository_url($repoid);
|
||||
$repository = new \repository_url($repoid);
|
||||
$repository->get_listing();
|
||||
} catch (repository_exception $e) {
|
||||
} catch (\repository_exception $e) {
|
||||
if ($e->errorcode == 'validfiletype') {
|
||||
$caughtexception = true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
* @copyright 2016 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_webservice;
|
||||
|
||||
use webservice;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
@@ -35,7 +39,7 @@ require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
* @copyright 2016 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_test extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Setup.
|
||||
@@ -60,7 +64,7 @@ class webservice_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Add a web service.
|
||||
$webservice = new stdClass();
|
||||
$webservice = new \stdClass();
|
||||
$webservice->name = 'Test web service';
|
||||
$webservice->enabled = true;
|
||||
$webservice->restrictedusers = false;
|
||||
@@ -71,7 +75,7 @@ class webservice_test extends advanced_testcase {
|
||||
$externalserviceid = $DB->insert_record('external_services', $webservice);
|
||||
|
||||
// Add token.
|
||||
$externaltoken = new stdClass();
|
||||
$externaltoken = new \stdClass();
|
||||
$externaltoken->token = 'testtoken';
|
||||
$externaltoken->tokentype = 0;
|
||||
$externaltoken->userid = $USER->id;
|
||||
@@ -82,7 +86,7 @@ class webservice_test extends advanced_testcase {
|
||||
$DB->insert_record('external_tokens', $externaltoken);
|
||||
|
||||
// Add a function to the service.
|
||||
$wsmethod = new stdClass();
|
||||
$wsmethod = new \stdClass();
|
||||
$wsmethod->externalserviceid = $externalserviceid;
|
||||
$wsmethod->functionname = 'core_course_get_contents';
|
||||
$DB->insert_record('external_services_functions', $wsmethod);
|
||||
@@ -121,7 +125,7 @@ class webservice_test extends advanced_testcase {
|
||||
// Check the contents of service methods.
|
||||
foreach ($servicemethods as $method) {
|
||||
// Get the external function info.
|
||||
$function = external_api::external_function_info($method->name);
|
||||
$function = \external_api::external_function_info($method->name);
|
||||
|
||||
// Check input params.
|
||||
foreach ($function->parameters_desc->keys as $name => $keydesc) {
|
||||
@@ -150,7 +154,7 @@ class webservice_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Add a web service.
|
||||
$webservice = new stdClass();
|
||||
$webservice = new \stdClass();
|
||||
$webservice->name = 'Test web service';
|
||||
$webservice->enabled = true;
|
||||
$webservice->restrictedusers = false;
|
||||
@@ -161,7 +165,7 @@ class webservice_test extends advanced_testcase {
|
||||
$DB->insert_record('external_services', $webservice);
|
||||
|
||||
// Add token.
|
||||
$tokenstr = external_create_service_token($webservice->name, context_system::instance()->id);
|
||||
$tokenstr = external_create_service_token($webservice->name, \context_system::instance()->id);
|
||||
$token = $DB->get_record('external_tokens', ['token' => $tokenstr]);
|
||||
|
||||
// Trigger last access once (at current time).
|
||||
@@ -358,14 +362,14 @@ class webservice_test extends advanced_testcase {
|
||||
/**
|
||||
* Class webservice_dummy.
|
||||
*
|
||||
* Dummy webservice class for testing the webservice_base_server class and enable us to expose variables we want to test.
|
||||
* Dummy webservice class for testing the \webservice_base_server class and enable us to expose variables we want to test.
|
||||
*
|
||||
* @package core_webservice
|
||||
* @category test
|
||||
* @copyright 2016 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_dummy extends webservice_base_server {
|
||||
class webservice_dummy extends \webservice_base_server {
|
||||
|
||||
/**
|
||||
* webservice_dummy constructor.
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2015 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace webservice_xmlrpc;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ require_once($CFG->dirroot . '/webservice/xmlrpc/lib.php');
|
||||
* @copyright 2015 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_xmlrpc_test extends advanced_testcase {
|
||||
class lib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Setup.
|
||||
@@ -85,7 +86,7 @@ class webservice_xmlrpc_test extends advanced_testcase {
|
||||
$client = new webservice_xmlrpc_client_mock('/webservice/xmlrpc/server.php', 'anytoken');
|
||||
$mockresponse = file_get_contents($CFG->dirroot . '/webservice/xmlrpc/tests/fixtures/fault_response.xml');
|
||||
$client->set_mock_response($mockresponse);
|
||||
$this->expectException('moodle_exception');
|
||||
$this->expectException('\moodle_exception');
|
||||
$client->call('testfunction');
|
||||
}
|
||||
|
||||
@@ -156,7 +157,7 @@ class webservice_xmlrpc_test extends advanced_testcase {
|
||||
* @copyright 2015 Jun Pataleta <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_xmlrpc_client_mock extends webservice_xmlrpc_client {
|
||||
class webservice_xmlrpc_client_mock extends \webservice_xmlrpc_client {
|
||||
|
||||
/** @var string The mock XML-RPC response string. */
|
||||
private $mockresponse;
|
||||
@@ -178,7 +179,7 @@ class webservice_xmlrpc_client_mock extends webservice_xmlrpc_client {
|
||||
* @param string $functionname the function name
|
||||
* @param array $params the parameters of the function
|
||||
* @return mixed The decoded XML RPC response.
|
||||
* @throws moodle_exception
|
||||
* @throws \moodle_exception
|
||||
*/
|
||||
public function call($functionname, $params = array()) {
|
||||
// Get the response.
|
||||
@@ -188,7 +189,7 @@ class webservice_xmlrpc_client_mock extends webservice_xmlrpc_client {
|
||||
// Decode the response.
|
||||
$result = xmlrpc_decode($response);
|
||||
if (is_array($result) && xmlrpc_is_fault($result)) {
|
||||
throw new moodle_exception($result['faultString']);
|
||||
throw new \moodle_exception($result['faultString']);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace webservice_xmlrpc;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -36,7 +37,7 @@ require_once($CFG->dirroot . '/webservice/xmlrpc/locallib.php');
|
||||
* @copyright 2016 Cameron Ball
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_xmlrpc_locallib_testcase extends advanced_testcase {
|
||||
class locallib_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Setup.
|
||||
@@ -70,7 +71,7 @@ class webservice_xmlrpc_locallib_testcase extends advanced_testcase {
|
||||
|
||||
$func = $rc->getProperty('function');
|
||||
$func->setAccessible(true);
|
||||
$func->setValue($server, (object) ['returns_desc' => new external_value(PARAM_RAW, $returnsdesc, VALUE_OPTIONAL)]);
|
||||
$func->setValue($server, (object) ['returns_desc' => new \external_value(PARAM_RAW, $returnsdesc, VALUE_OPTIONAL)]);
|
||||
|
||||
$ret = $rc->getProperty('returns');
|
||||
$ret->setAccessible(true);
|
||||
|
||||
Reference in New Issue
Block a user