Skip to content

Commit

Permalink
Merge branch 'MDL-67673' of https://github.com/stronk7/moodle into ma…
Browse files Browse the repository at this point in the history
…ster
  • Loading branch information
sarjona committed Oct 21, 2020
2 parents 06fdc6a + 07c1522 commit ca2db4b
Show file tree
Hide file tree
Showing 597 changed files with 4,094 additions and 2,956 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CVS
/.project
/.buildpath
/.cache
.phpunit.result.cache
phpunit.xml
# Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us.
composer.phar
Expand Down
14 changes: 7 additions & 7 deletions admin/roles/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function test_get_users_in_context() {
$user1->id,
$admin->id
];
$this->assertEquals($expected, $userlist2->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist2->get_userids());

// The user list for coursecontext1 should user1, user2 and admin (role creator).
$userlist3 = new \core_privacy\local\request\userlist($coursecontext1, $component);
Expand All @@ -547,7 +547,7 @@ public function test_get_users_in_context() {
$user2->id,
$admin->id
];
$this->assertEquals($expected, $userlist3->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist3->get_userids());

// The user list for coursecatcontext should user2 and admin (role creator).
$userlist4 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
Expand All @@ -557,7 +557,7 @@ public function test_get_users_in_context() {
$user2->id,
$admin->id
];
$this->assertEquals($expected, $userlist4->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist4->get_userids());

// The user list for systemcontext should user1 and admin (role creator).
$userlist6 = new \core_privacy\local\request\userlist($systemcontext, $component);
Expand All @@ -567,7 +567,7 @@ public function test_get_users_in_context() {
$user1->id,
$admin->id
];
$this->assertEquals($expected, $userlist6->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist6->get_userids());

// The user list for cmcontext should user1, user2 and admin (role creator).
$userlist7 = new \core_privacy\local\request\userlist($cmcontext, $component);
Expand All @@ -578,7 +578,7 @@ public function test_get_users_in_context() {
$user2->id,
$admin->id
];
$this->assertEquals($expected, $userlist7->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist7->get_userids());

// The user list for blockcontext should user1 and admin (role creator).
$userlist8 = new \core_privacy\local\request\userlist($blockcontext, $component);
Expand All @@ -588,7 +588,7 @@ public function test_get_users_in_context() {
$user1->id,
$admin->id
];
$this->assertEquals($expected, $userlist8->get_userids(), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing($expected, $userlist8->get_userids());
}

/**
Expand Down Expand Up @@ -744,4 +744,4 @@ protected static function get_roles_name() {
}
return $rolesnames;
}
}
}
3 changes: 1 addition & 2 deletions admin/tool/analytics/tests/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ public function test_potential_contexts() {

/**
* test_potential_contexts description
*
* @expectedException required_capability_exception
*/
public function test_potential_contexts_no_manager() {
$this->resetAfterTest();

$user = $this->getDataGenerator()->create_user();
$this->setUser($user);

$this->expectException(required_capability_exception::class);
$this->assertCount(2, \tool_analytics\external::potential_contexts());
}
}
30 changes: 15 additions & 15 deletions admin/tool/behat/tests/manager_util_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
/**
* Setup test.
*/
public function setup() {
public function setUp(): void {
global $CFG;

$this->resetAfterTest();
Expand Down Expand Up @@ -165,7 +165,7 @@ public function test_get_config_file_contents_with_single_run() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand Down Expand Up @@ -219,7 +219,7 @@ public function test_get_config_file_contents_with_single_run_no_theme() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand Down Expand Up @@ -264,7 +264,7 @@ public function test_get_config_file_contents_with_parallel_run() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand Down Expand Up @@ -295,7 +295,7 @@ public function test_get_config_file_contents_with_parallel_run() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -324,7 +324,7 @@ public function test_get_config_file_contents_with_parallel_run() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -368,7 +368,7 @@ public function test_get_config_file_contents_with_parallel_run_optimize_tags()
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -399,7 +399,7 @@ public function test_get_config_file_contents_with_parallel_run_optimize_tags()
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -428,7 +428,7 @@ public function test_get_config_file_contents_with_parallel_run_optimize_tags()
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -532,7 +532,7 @@ public function test_get_config_file_contents_with_blacklisted_tags() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -611,7 +611,7 @@ public function test_get_config_file_contents_with_blacklisted_features_contexts
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
Expand Down Expand Up @@ -646,7 +646,7 @@ public function test_core_features_to_include_in_specified_theme() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand All @@ -662,7 +662,7 @@ public function test_core_features_to_include_in_specified_theme() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand All @@ -678,7 +678,7 @@ public function test_core_features_to_include_in_specified_theme() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}

Expand All @@ -693,7 +693,7 @@ public function test_core_features_to_include_in_specified_theme() {
$this->assertCount(count($paths), $suites[$themename]['paths']);

foreach ($paths as $key => $feature) {
$this->assertContains($feature, $suites[$themename]['paths'][$key]);
$this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/capability/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class tool_capability_events_testcase extends advanced_testcase {
/**
* Setup testcase.
*/
public function setUp() {
public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
Expand Down
18 changes: 5 additions & 13 deletions admin/tool/cohortroles/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
/**
* Setup function- we will create a course and add an assign instance to it.
*/
protected function setUp() {
protected function setUp(): void {
$this->resetAfterTest(true);

// Create some users.
Expand All @@ -60,29 +60,25 @@ protected function setUp() {
cohort_add_member($this->cohort->id, $this->userassignover->id);
}

/**
* @expectedException required_capability_exception
*/
public function test_create_cohort_role_assignment_without_permission() {
$this->setUser($this->userassignto);
$params = (object) array(
'userid' => $this->userassignto->id,
'roleid' => $this->roleid,
'cohortid' => $this->cohort->id
);
$this->expectException(required_capability_exception::class);
api::create_cohort_role_assignment($params);
}

/**
* @expectedException core_competency\invalid_persistent_exception
*/
public function test_create_cohort_role_assignment_with_invalid_data() {
$this->setAdminUser();
$params = (object) array(
'userid' => $this->userassignto->id,
'roleid' => -8,
'cohortid' => $this->cohort->id
);
$this->expectException(\core_competency\invalid_persistent_exception::class);
api::create_cohort_role_assignment($params);
}

Expand All @@ -100,9 +96,6 @@ public function test_create_cohort_role_assignment() {
$this->assertEquals($result->get('cohortid'), $this->cohort->id);
}

/**
* @expectedException required_capability_exception
*/
public function test_delete_cohort_role_assignment_without_permission() {
$this->setAdminUser();
$params = (object) array(
Expand All @@ -112,12 +105,10 @@ public function test_delete_cohort_role_assignment_without_permission() {
);
$result = api::create_cohort_role_assignment($params);
$this->setUser($this->userassignto);
$this->expectException(required_capability_exception::class);
api::delete_cohort_role_assignment($result->get('id'));
}

/**
* @expectedException dml_missing_record_exception
*/
public function test_delete_cohort_role_assignment_with_invalid_data() {
$this->setAdminUser();
$params = (object) array(
Expand All @@ -126,6 +117,7 @@ public function test_delete_cohort_role_assignment_with_invalid_data() {
'cohortid' => $this->cohort->id
);
$result = api::create_cohort_role_assignment($params);
$this->expectException(dml_missing_record_exception::class);
api::delete_cohort_role_assignment($result->get('id') + 1);
}

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/cohortroles/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
/**
* Overriding setUp() function to always reset after tests.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
}

Expand Down Expand Up @@ -87,7 +87,7 @@ public function test_get_contexts_for_userid() {
CONTEXT_COURSECAT
];
// Test the User's contexts equal the system and course category context.
$this->assertEquals($expected, $contextlevels, '', 0, 10, true);
$this->assertEqualsCanonicalizing($expected, $contextlevels);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/dataprivacy/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ public function test_notify_dpo($byadmin, $type, $typestringid, $comments) {
$this->assertEquals($subject, $message->subject);
$this->assertEquals('tool_dataprivacy', $message->component);
$this->assertEquals('contactdataprotectionofficer', $message->eventtype);
$this->assertContains(fullname($dpo), $message->fullmessage);
$this->assertContains(fullname($user1), $message->fullmessage);
$this->assertStringContainsString(fullname($dpo), $message->fullmessage);
$this->assertStringContainsString(fullname($user1), $message->fullmessage);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc
/**
* Test tearDown.
*/
public function tearDown() {
public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/dataprivacy/tests/manager_observer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function test_handle_component_failure() {
return $message->useridto;
}, $messages);

$this->assertEquals(array_keys($dpos), $messageusers, '', 0.0, 0, true);
$this->assertEqualsCanonicalizing(array_keys($dpos), $messageusers);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/dataprivacy/tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function test_export_user_data() {
$this->assertEquals($strs->statusrejected, $data[1]->status);
$this->assertEquals($strs->creationmanual, $data[1]->creationmethod);
$this->assertEmpty($data[1]->comments);
$this->assertContains('Nope', $data[1]->dpocomment);
$this->assertStringContainsString('Nope', $data[1]->dpocomment);
$this->assertNotEmpty($data[1]->timecreated);
}

Expand Down Expand Up @@ -184,4 +184,4 @@ public function test_export_user_preferences() {

$this->assertEquals(6, $preferences[helper::PREF_REQUEST_PERPAGE]->value);
}
}
}
2 changes: 1 addition & 1 deletion admin/tool/dataprivacy/tests/task_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class tool_dataprivacy_task_testcase extends data_privacy_testcase {
/**
* Test tearDown.
*/
public function tearDown() {
public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}

Expand Down
Loading

0 comments on commit ca2db4b

Please sign in to comment.