forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-73352 phpunit: lib_test and locallib_test testcase names
All lib_test and locallib_test classes: - Namespaced with component (and API whenever makes sense). - Fixed incorrect use statements with leading backslash. - Changed code to point to global scope when needed or add new uses. - All them passing individually. - Complete runs passing too. Special mention to tests under login/tests: 1) The core_login component doesn't exist. 2) But login/tests are allowed because there is a suite pointing to it (phpunit.xml). 3) So, the only possible namespace for them is "core". 4) And to avoid problems with other core testcases (under lib/tests) they have been renamed to have login_xxxx as prefix.
- Loading branch information
Showing
62 changed files
with
970 additions
and
839 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 @@ | |
* @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 @@ public function test_get_events_with_disabled_module() { | |
] | ||
]; | ||
foreach ($events as $event) { | ||
calendar_event::create($event, false); | ||
\calendar_event::create($event, false); | ||
} | ||
$timestart = time() - 60; | ||
$timeend = time() + 60; | ||
|
@@ -145,7 +146,7 @@ public function test_get_course_cached() { | |
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 @@ public function test_update_subscription() { | |
$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 @@ public function test_add_subscription() { | |
$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 @@ public function test_add_subscription() { | |
$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 @@ public function test_add_subscription() { | |
$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 @@ public function test_add_subscription() { | |
$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 @@ public function test_get_legacy_events_with_overrides() { | |
]; | ||
|
||
foreach ($events as $event) { | ||
calendar_event::create($event, false); | ||
\calendar_event::create($event, false); | ||
} | ||
|
||
$timestart = $now - 100; | ||
|
@@ -432,7 +433,7 @@ public function test_get_legacy_events_with_overrides() { | |
]; | ||
|
||
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 @@ public function test_calendar_get_default_courses() { | |
$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 @@ public function test_calendar_get_allowed_event_types_course() { | |
$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 @@ public function test_calendar_get_allowed_event_types_group_no_acces_to_diff_gro | |
$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 @@ public function test_calendar_get_allowed_event_types_group_no_groups() { | |
$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 @@ public function test_calendar_get_allowed_event_types_group_access_all_groups() | |
$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 @@ public function test_calendar_get_allowed_event_types_group_no_access_all_groups | |
$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 @@ public function test_calendar_get_allowed_event_types_group_cap_no_groups() { | |
$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 @@ public function test_calendar_get_allowed_event_types_group_cap_has_group() { | |
$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 @@ public function test_calendar_get_allowed_event_types_group_cap_access_all_group | |
$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 @@ public function test_calendar_view_event_allowed_course_event() { | |
'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)); | ||
|
Oops, something went wrong.