From 3a5641cb74cc27453be4a83c98aae2a104678ed1 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 2 Sep 2020 01:14:14 +0200 Subject: [PATCH] MDL-67673 phpunit: Remove deprecated assertEquals() params The optional parameters of assertEquals() and assertNotEquals() are deprecated in PHPUnit 8 (to be removed in PHPUnit 9): - delta => use assertEqualsWithDelta() - canonicalize => use assertEqualsCanonicalizing() - ignoreCase => use assertEqualsIgnoringCase - maxDepth => removed without replacement. More info @ https://github.com/sebastianbergmann/phpunit/issues/3341 Initial search done with: ag 'assert(Not)?Equals\(.*,.*,' --php Then, running tests and fixing remaining cases. --- admin/roles/tests/privacy_test.php | 14 +++--- admin/tool/cohortroles/tests/privacy_test.php | 2 +- .../tests/manager_observer_test.php | 2 +- .../policy/tests/privacy_provider_test.php | 10 ++--- admin/tool/uploadcourse/tests/course_test.php | 2 +- auth/oauth2/tests/auth_test.php | 5 +-- backup/tests/privacy_provider_test.php | 2 +- .../comments/tests/privacy_provider_test.php | 2 +- blog/tests/privacy_test.php | 2 +- cache/tests/fixtures/stores.php | 4 +- calendar/tests/lib_test.php | 13 +++--- .../raw_event_retrieval_strategy_test.php | 10 ++--- course/tests/externallib_test.php | 2 +- customfield/tests/privacy_test.php | 4 +- .../flatfile/tests/privacy_provider_test.php | 12 ++---- enrol/lti/tests/privacy_provider_test.php | 7 ++- enrol/meta/tests/privacy_test.php | 5 +-- enrol/paypal/tests/privacy_provider_test.php | 43 ++++++++----------- enrol/tests/enrollib_test.php | 2 +- enrol/tests/externallib_test.php | 7 ++- favourites/tests/privacy_test.php | 2 +- grade/tests/edittreelib_test.php | 2 +- grade/tests/privacy_test.php | 4 +- group/tests/privacy_provider_test.php | 19 ++++---- iplookup/tests/geoplugin_test.php | 4 +- lib/ddl/tests/ddl_test.php | 6 +-- lib/dml/tests/dml_test.php | 6 +-- lib/grade/tests/grade_item_test.php | 12 +++--- lib/phpunit/tests/basic_test.php | 2 +- lib/tests/accesslib_test.php | 11 ++--- lib/tests/blocklib_test.php | 28 ++++++------ lib/tests/filterlib_test.php | 2 +- lib/tests/grouplib_test.php | 16 +++---- lib/tests/mathslib_test.php | 10 ++--- lib/tests/moodlelib_test.php | 2 +- lib/tests/session_manager_test.php | 4 +- lib/tests/time_splittings_test.php | 14 +++--- message/tests/privacy_provider_test.php | 2 +- mod/data/tests/lib_test.php | 2 +- mod/glossary/tests/external_test.php | 8 ++-- .../statistics/tests/statistics_test.php | 2 +- .../stats_from_steps_walkthrough_test.php | 13 +++--- .../local_structure_slot_random_test.php | 7 ++- mod/quiz/tests/locallib_test.php | 14 +++--- mod/quiz/tests/privacy_provider_test.php | 5 +-- mod/quiz/tests/tags_test.php | 5 +-- mod/wiki/tests/lib_test.php | 12 +++--- mod/wiki/tests/privacy_test.php | 14 +++--- mod/workshop/tests/privacy_provider_test.php | 14 +++--- .../adaptive/tests/walkthrough_test.php | 2 +- .../tests/walkthrough_test.php | 2 +- .../deferredcbm/tests/question_cbm_test.php | 24 +++++------ .../deferredcbm/tests/walkthrough_test.php | 2 +- .../tests/walkthrough_test.php | 2 +- .../immediatecbm/tests/walkthrough_test.php | 2 +- .../tests/walkthrough_test.php | 2 +- .../interactive/tests/walkthrough_test.php | 2 +- question/engine/tests/helpers.php | 4 +- .../engine/tests/questionattemptstep_test.php | 2 +- question/engine/tests/unitofwork_test.php | 2 +- question/tests/privacy_provider_test.php | 7 ++- .../type/ddwtos/tests/questiontype_test.php | 2 +- .../gapselect/tests/questiontype_test.php | 2 +- .../type/match/tests/questiontype_test.php | 2 +- .../multianswer/tests/questiontype_test.php | 2 +- .../multichoice/tests/question_multi_test.php | 2 +- .../tests/question_single_test.php | 2 +- .../numerical/tests/answerprocessor_test.php | 4 +- repository/contentbank/tests/browser_test.php | 14 +++--- repository/contentbank/tests/search_test.php | 8 ++-- 70 files changed, 220 insertions(+), 263 deletions(-) diff --git a/admin/roles/tests/privacy_test.php b/admin/roles/tests/privacy_test.php index 258b5a70541c8..82203c16a08fa 100644 --- a/admin/roles/tests/privacy_test.php +++ b/admin/roles/tests/privacy_test.php @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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()); } /** @@ -744,4 +744,4 @@ protected static function get_roles_name() { } return $rolesnames; } -} \ No newline at end of file +} diff --git a/admin/tool/cohortroles/tests/privacy_test.php b/admin/tool/cohortroles/tests/privacy_test.php index 72446a2e83414..e5c4b9c9a6b06 100644 --- a/admin/tool/cohortroles/tests/privacy_test.php +++ b/admin/tool/cohortroles/tests/privacy_test.php @@ -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); } /** diff --git a/admin/tool/dataprivacy/tests/manager_observer_test.php b/admin/tool/dataprivacy/tests/manager_observer_test.php index 1c471536fd34b..a68bd886ef39d 100644 --- a/admin/tool/dataprivacy/tests/manager_observer_test.php +++ b/admin/tool/dataprivacy/tests/manager_observer_test.php @@ -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); } /** diff --git a/admin/tool/policy/tests/privacy_provider_test.php b/admin/tool/policy/tests/privacy_provider_test.php index 6fa4a0d6c115d..e0d5ea58105d6 100644 --- a/admin/tool/policy/tests/privacy_provider_test.php +++ b/admin/tool/policy/tests/privacy_provider_test.php @@ -274,13 +274,9 @@ public function test_export_agreements_for_other() { // Request export for the manager. $contextlist = provider::get_contexts_for_userid($this->manager->id); $this->assertCount(3, $contextlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$managercontext->id, $usercontext->id, $systemcontext->id], - $contextlist->get_contextids(), - '', - 0.0, - 1, - true + $contextlist->get_contextids() ); $approvedcontextlist = new approved_contextlist($this->user, 'tool_policy', [$usercontext->id]); @@ -332,7 +328,7 @@ public function test_export_created_policies() { // Agree to the policies for oneself. $contextlist = provider::get_contexts_for_userid($this->manager->id); $this->assertCount(2, $contextlist); - $this->assertEquals([$managercontext->id, $systemcontext->id], $contextlist->get_contextids(), '', 0.0, 1, true); + $this->assertEqualsCanonicalizing([$managercontext->id, $systemcontext->id], $contextlist->get_contextids()); $approvedcontextlist = new approved_contextlist($this->manager, 'tool_policy', $contextlist->get_contextids()); provider::export_user_data($approvedcontextlist); diff --git a/admin/tool/uploadcourse/tests/course_test.php b/admin/tool/uploadcourse/tests/course_test.php index 400e7ea1583f9..cd3dd413a6254 100644 --- a/admin/tool/uploadcourse/tests/course_test.php +++ b/admin/tool/uploadcourse/tests/course_test.php @@ -1228,7 +1228,7 @@ public function test_custom_fields_data() { // Confirm presence of course custom fields. $data = \core_course\customfield\course_handler::create()->export_instance_data_object($course->id); - $this->assertEquals('Wednesday, 1 April 2020, 4:00 PM', $data->mydatefield, '', 0.0, 10, false, true); + $this->assertEqualsIgnoringCase('Wednesday, 1 April 2020, 4:00 PM', $data->mydatefield); $this->assertEquals($dataupload['customfield_mytextfield'], $data->mytextfield); $this->assertStringContainsString($dataupload['customfield_mytextareafield'], $data->mytextareafield); } diff --git a/auth/oauth2/tests/auth_test.php b/auth/oauth2/tests/auth_test.php index 71bbce2cea115..4582d7081ee46 100644 --- a/auth/oauth2/tests/auth_test.php +++ b/auth/oauth2/tests/auth_test.php @@ -42,10 +42,7 @@ public function test_get_password_change_info() { $auth = get_auth_plugin($user->auth); $info = $auth->get_password_change_info($user); - $this->assertEquals( - ['subject', 'message'], - array_keys($info), - '', 0.0, 10, true); + $this->assertEqualsCanonicalizing(['subject', 'message'], array_keys($info)); $this->assertStringContainsString( 'your password cannot be reset because you are using your account on another site to log in', $info['message']); diff --git a/backup/tests/privacy_provider_test.php b/backup/tests/privacy_provider_test.php index 4bec91e9d389f..aec7eb63586be 100644 --- a/backup/tests/privacy_provider_test.php +++ b/backup/tests/privacy_provider_test.php @@ -482,7 +482,7 @@ public function test_delete_data_for_users() { $this->assertCount(2, $userlist1); $expected = [$user1->id, $user2->id]; $actual = $userlist1->get_userids(); - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); // The list of users for coursecontext2 should not return users. $userlist2 = new \core_privacy\local\request\userlist($coursecontext2, $component); diff --git a/blocks/comments/tests/privacy_provider_test.php b/blocks/comments/tests/privacy_provider_test.php index 1962cc13d6d0e..e239ba7a106b3 100644 --- a/blocks/comments/tests/privacy_provider_test.php +++ b/blocks/comments/tests/privacy_provider_test.php @@ -209,7 +209,7 @@ public function test_get_contexts_for_userid() { $this->assertCount(2, $contextlist); $contextids = $contextlist->get_contextids(); - $this->assertEquals([$coursecontext1->id, $coursecontext2->id], $contextids, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$coursecontext1->id, $coursecontext2->id], $contextids); } /** diff --git a/blog/tests/privacy_test.php b/blog/tests/privacy_test.php index 67de624c045b3..5eab70b7816f4 100644 --- a/blog/tests/privacy_test.php +++ b/blog/tests/privacy_test.php @@ -690,7 +690,7 @@ public function test_export_data_for_user() { $commentpath = array_merge($path, [get_string('commentsubcontext', 'core_comment')]); if ($e->id == $e1->id) { $tagdata = $writer->get_related_data($path, 'tags'); - $this->assertEquals(['Beer', 'Golf'], $tagdata, '', 0, 10, true); + $this->assertEqualsCanonicalizing(['Beer', 'Golf'], $tagdata); $comments = $writer->get_data($commentpath); $this->assertCount(2, $comments->comments); diff --git a/cache/tests/fixtures/stores.php b/cache/tests/fixtures/stores.php index 36329c4ab62d3..f415272c88c30 100644 --- a/cache/tests/fixtures/stores.php +++ b/cache/tests/fixtures/stores.php @@ -116,10 +116,10 @@ public function run_tests(cache_store $instance) { // Test find and find with prefix if this class implements the searchable interface. if ($instance->is_searchable()) { // Extra settings here ignore the return order of the array. - $this->assertEquals(['test3', 'test1', 'test2', 'other3'], $instance->find_all(), '', 0, 1, true); + $this->assertEqualsCanonicalizing(['test3', 'test1', 'test2', 'other3'], $instance->find_all()); // Extra settings here ignore the return order of the array. - $this->assertEquals(['test2', 'test1', 'test3'], $instance->find_by_prefix('test'), '', 0, 1, true); + $this->assertEqualsCanonicalizing(['test2', 'test1', 'test3'], $instance->find_by_prefix('test')); $this->assertEquals(['test2'], $instance->find_by_prefix('test2')); $this->assertEquals(['other3'], $instance->find_by_prefix('other')); $this->assertEquals([], $instance->find_by_prefix('nothere')); diff --git a/calendar/tests/lib_test.php b/calendar/tests/lib_test.php index d39012581cf44..6fb459df8b6e4 100644 --- a/calendar/tests/lib_test.php +++ b/calendar/tests/lib_test.php @@ -827,10 +827,9 @@ public function test_calendar_set_filters_not_logged_in() { $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id); list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID], - array_values($courseids), - '', 0.0, 10, true); + array_values($courseids)); $this->assertFalse($groupids); $this->assertFalse($userid); } @@ -853,10 +852,9 @@ public function test_calendar_set_filters_not_logged_in_with_user() { $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id); list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false, $users[0]); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID], - array_values($courseids), - '', 0.0, 10, true); + array_values($courseids)); $this->assertEquals(array($coursegroups[$courses[0]->id][0]->id), $groupids); $this->assertEquals($users[0]->id, $userid); @@ -873,8 +871,7 @@ public function test_calendar_set_filters_logged_in_no_user() { $this->setUser($users[0]); $defaultcourses = calendar_get_default_courses(null, '*', false, $users[0]->id); list($courseids, $groupids, $userid) = calendar_set_filters($defaultcourses, false); - $this->assertEquals([$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID], array_values($courseids), '', 0.0, 10, - true); + $this->assertEqualsCanonicalizing([$courses[0]->id, $courses[1]->id, $courses[2]->id, SITEID], array_values($courseids)); $this->assertEquals(array($coursegroups[$courses[0]->id][0]->id), $groupids); $this->assertEquals($users[0]->id, $userid); } diff --git a/calendar/tests/raw_event_retrieval_strategy_test.php b/calendar/tests/raw_event_retrieval_strategy_test.php index b195eeaf6eafd..5bedcb15e745f 100644 --- a/calendar/tests/raw_event_retrieval_strategy_test.php +++ b/calendar/tests/raw_event_retrieval_strategy_test.php @@ -402,10 +402,9 @@ public function test_get_raw_events_for_multiple_users() { // Get all events. $events = $retrievalstrategy->get_raw_events([$user1->id, $user2->id]); $this->assertCount(2, $events); - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['User1 Event', 'User2 Event'], - array_column($events, 'name'), - '', 0.0, 10, true); + array_column($events, 'name')); } public function test_get_raw_events_for_groups_with_no_members() { @@ -442,10 +441,9 @@ public function test_get_raw_events_for_groups_with_no_members() { // Get group eventsl. $events = $retrievalstrategy->get_raw_events(null, [$group1->id, $group2->id]); $this->assertCount(2, $events); - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['Group 1 Event', 'Group 2 Event'], - array_column($events, 'name'), - '', 0.0, 10, true); + array_column($events, 'name')); } /** diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index f6bc7b6e9edfd..766a0c1a6dcc9 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -240,7 +240,7 @@ public function test_get_categories() { $returnedids[] = $category['id']; } // Sort the arrays upon comparision. - $this->assertEquals(array_keys($generatedcats), $returnedids, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing(array_keys($generatedcats), $returnedids); // Check different params. $categories = core_course_external::get_categories(array( diff --git a/customfield/tests/privacy_test.php b/customfield/tests/privacy_test.php index 4a63085fb3f20..6f9a480c18d1d 100644 --- a/customfield/tests/privacy_test.php +++ b/customfield/tests/privacy_test.php @@ -116,9 +116,9 @@ public function test_get_customfields_data_contexts() { list($sql, $params) = $DB->get_in_or_equal([$courses[1]->id, $courses[2]->id], SQL_PARAMS_NAMED); $r = provider::get_customfields_data_contexts('core_course', 'course', '=0', $sql, $params); - $this->assertEquals([context_course::instance($courses[1]->id)->id, + $this->assertEqualsCanonicalizing([context_course::instance($courses[1]->id)->id, context_course::instance($courses[2]->id)->id], - $r->get_contextids(), '', 0, 10, true); + $r->get_contextids()); } /** diff --git a/enrol/flatfile/tests/privacy_provider_test.php b/enrol/flatfile/tests/privacy_provider_test.php index 0b99cfc0906e7..7c9f22d5b0e0a 100644 --- a/enrol/flatfile/tests/privacy_provider_test.php +++ b/enrol/flatfile/tests/privacy_provider_test.php @@ -218,11 +218,9 @@ public function test_get_users_in_context() { // We expect to see 3 entries for course1, and that's user1, user3 and user4. $userlist = new \core_privacy\local\request\userlist($this->coursecontext1, 'enrol_flatfile'); provider::get_users_in_context($userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->user1->id, $this->user3->id, $this->user4->id], - $userlist->get_userids(), - '', 0.0, 10, true - ); + $userlist->get_userids()); // And 1 for course2 which is for user2. $userlist = new \core_privacy\local\request\userlist($this->coursecontext2, 'enrol_flatfile'); @@ -247,11 +245,9 @@ public function test_delete_data_for_users() { // Verify we have 3 future enrolment for user 1, user 3 and user 4. $userlist = new \core_privacy\local\request\userlist($this->coursecontext1, 'enrol_flatfile'); provider::get_users_in_context($userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->user1->id, $this->user3->id, $this->user4->id], - $userlist->get_userids(), - '', 0.0, 10, true - ); + $userlist->get_userids()); $approveduserlist = new \core_privacy\local\request\approved_userlist($this->coursecontext1, 'enrol_flatfile', [$this->user1->id, $this->user3->id]); diff --git a/enrol/lti/tests/privacy_provider_test.php b/enrol/lti/tests/privacy_provider_test.php index dfcaf07dc2ddd..16ebcb1fc15c0 100644 --- a/enrol/lti/tests/privacy_provider_test.php +++ b/enrol/lti/tests/privacy_provider_test.php @@ -92,7 +92,7 @@ public function test_get_contexts_for_userid() { $expectedids = [$coursectx->id, $activityctx->id]; $actualids = $contextlist->get_contextids(); - $this->assertEquals($expectedids, $actualids, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expectedids, $actualids); } /** @@ -211,10 +211,9 @@ public function test_get_users_in_context_course() { $userlist = new \core_privacy\local\request\userlist($coursecontext, 'enrol_paypal'); provider::get_users_in_context($userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->user->id, $this->anotheruser->id], - $userlist->get_userids(), - '', 0.0, 10, true); + $userlist->get_userids()); } /** diff --git a/enrol/meta/tests/privacy_test.php b/enrol/meta/tests/privacy_test.php index d9951b2b4836d..60ed24cfd537f 100644 --- a/enrol/meta/tests/privacy_test.php +++ b/enrol/meta/tests/privacy_test.php @@ -294,9 +294,8 @@ public function test_get_users_in_context() { $userlist = new \core_privacy\local\request\userlist($context, 'enrol_meta'); \enrol_meta\privacy\provider::get_users_in_context($userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$user1->id, $user2->id], - $userlist->get_userids(), - '', 0.0, 10, true); + $userlist->get_userids()); } } diff --git a/enrol/paypal/tests/privacy_provider_test.php b/enrol/paypal/tests/privacy_provider_test.php index 25b63042b42ab..391a7d9cf2de7 100644 --- a/enrol/paypal/tests/privacy_provider_test.php +++ b/enrol/paypal/tests/privacy_provider_test.php @@ -302,7 +302,7 @@ public function test_get_contexts_for_userid_business() { $this->assertCount(2, $contextlist); $contextids = $contextlist->get_contextids(); - $this->assertEquals([$coursecontext1->id, $coursecontext2->id], $contextids, '', 0.0, 1, true); + $this->assertEqualsCanonicalizing([$coursecontext1->id, $coursecontext2->id], $contextids); // Business User 3 is the Receiver of course 3 only. $contextlist = provider::get_contexts_for_userid($this->businessuser3->id); @@ -368,11 +368,9 @@ public function test_export_user_data_multiple_paypal_history() { $data = $writer->get_data([get_string('transactions', 'enrol_paypal')]); $this->assertCount(2, $data->transactions); - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['STUDENT2-IN-COURSE2-00', 'STUDENT2-IN-COURSE2-01'], - array_column($data->transactions, 'txn_id'), - '', 0.0, 10, true - ); + array_column($data->transactions, 'txn_id')); } /** @@ -674,7 +672,7 @@ public function test_get_users_in_context() { $userlist1 = new \core_privacy\local\request\userlist($coursecontext1, 'enrol_paypal'); provider::get_users_in_context($userlist1); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ $this->businessuser1->id, $this->businessuser2->id, @@ -682,13 +680,12 @@ public function test_get_users_in_context() { $this->student1->id, $this->student12->id ], - $userlist1->get_userids(), - '', 0.0, 10, true + $userlist1->get_userids() ); $userlist2 = new \core_privacy\local\request\userlist($coursecontext2, 'enrol_paypal'); provider::get_users_in_context($userlist2); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ $this->businessuser1->id, $this->businessuser2->id, @@ -696,20 +693,18 @@ public function test_get_users_in_context() { $this->student2->id, $this->student12->id ], - $userlist2->get_userids(), - '', 0.0, 10, true + $userlist2->get_userids() ); $userlist3 = new \core_privacy\local\request\userlist($coursecontext3, 'enrol_paypal'); provider::get_users_in_context($userlist3); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ $this->businessuser3->id, $this->receiveruser3->id, $this->student3->id ], - $userlist3->get_userids(), - '', 0.0, 10, true + $userlist3->get_userids() ); } @@ -729,16 +724,14 @@ public function test_delete_data_for_users() { 2, $DB->count_records('enrol_paypal', ['courseid' => $this->course1->id]) ); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->course1->id, $this->course2->id], - $DB->get_fieldset_select('enrol_paypal', 'courseid', 'userid = ?', [$this->student12->id]), - '', 0.0, 10, true + $DB->get_fieldset_select('enrol_paypal', 'courseid', 'userid = ?', [$this->student12->id]) ); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->course1->id, $this->course2->id, $this->course2->id], $DB->get_fieldset_select('enrol_paypal', 'courseid', 'business = ?', - [\core_text::strtolower($this->businessuser1->email)]), - '', 0.0, 10, true + [\core_text::strtolower($this->businessuser1->email)]) ); $this->assertEquals( 3, @@ -760,16 +753,14 @@ public function test_delete_data_for_users() { 1, $DB->count_records('enrol_paypal', ['courseid' => $this->course1->id]) ); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->course2->id], - $DB->get_fieldset_select('enrol_paypal', 'courseid', 'userid = ?', [$this->student12->id]), - '', 0.0, 10, true + $DB->get_fieldset_select('enrol_paypal', 'courseid', 'userid = ?', [$this->student12->id]) ); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$this->course2->id, $this->course2->id], $DB->get_fieldset_select('enrol_paypal', 'courseid', 'business = ?', - [\core_text::strtolower($this->businessuser1->email)]), - '', 0.0, 10, true + [\core_text::strtolower($this->businessuser1->email)]) ); $this->assertEquals( 3, diff --git a/enrol/tests/enrollib_test.php b/enrol/tests/enrollib_test.php index 9604b198441ae..0965efa2e729d 100644 --- a/enrol/tests/enrollib_test.php +++ b/enrol/tests/enrollib_test.php @@ -159,7 +159,7 @@ public function test_enrol_get_all_users_courses() { $course = reset($courses); context_helper::preload_from_record($course); $course = (array)$course; - $this->assertEquals($basefields, array_keys($course), '', 0, 10, true); + $this->assertEqualsCanonicalizing($basefields, array_keys($course)); $courses = enrol_get_all_users_courses($user2->id, false, 'timecreated'); $course = reset($courses); diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php index 09a01ad2599cb..a12df0bb38be8 100644 --- a/enrol/tests/externallib_test.php +++ b/enrol/tests/externallib_test.php @@ -351,7 +351,7 @@ public function test_get_enrolled_users_visibility($settings, $results) { $viewed[] = $createdusers[$enrolleduser['id']]; } // Verify viewed matches canview expectation (using canonicalize to ignore ordering). - $this->assertEquals($canview, $viewed, "Problem checking visible users for '{$createdusers[$USER->id]}'", 0, 1, true); + $this->assertEqualsCanonicalizing($canview, $viewed, "Problem checking visible users for '{$createdusers[$USER->id]}'"); } } @@ -1150,10 +1150,9 @@ public function test_submit_user_enrolment_form($customdata, $expectedresult, $v core_enrol_external::submit_user_enrolment_form($querystring) ); - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['result' => $expectedresult, 'validationerror' => $validationerror], - $result, - '', 0.0, 10, true); + $result); if ($result['result']) { $ue = $DB->get_record('user_enrolments', ['id' => $ueid], '*', MUST_EXIST); diff --git a/favourites/tests/privacy_test.php b/favourites/tests/privacy_test.php index d7fe912b9b3b8..d7890eef6978b 100644 --- a/favourites/tests/privacy_test.php +++ b/favourites/tests/privacy_test.php @@ -164,7 +164,7 @@ public function test_add_userids_for_context() { $user1->id, $user2->id ]; - $this->assertEquals($expected, $userlist->get_userids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $userlist->get_userids()); // Ask the favourites privacy api to export userids for favourites of the type we just created, in the user1 context. $userlist = new \core_privacy\local\request\userlist($user1context, 'core_course'); diff --git a/grade/tests/edittreelib_test.php b/grade/tests/edittreelib_test.php index b24608d3c6f35..93d79836d9779 100644 --- a/grade/tests/edittreelib_test.php +++ b/grade/tests/edittreelib_test.php @@ -79,7 +79,7 @@ public function test_grade_edit_tree_column_range_get_item_cell() { $this->assertEquals(GRADE_TYPE_VALUE, $gradeitem->gradetype); $this->assertEquals(null, $gradeitem->scaleid); - $this->assertEquals(70.0, (float) $cell->text, "Grade text is 70", 0.01); + $this->assertEqualsWithDelta(70.0, (float) $cell->text, 0.01, "Grade text is 70"); // Now change it to a scale. $instance = $assign->get_instance(); diff --git a/grade/tests/privacy_test.php b/grade/tests/privacy_test.php index d721dee8f5216..e1b39597aff4e 100644 --- a/grade/tests/privacy_test.php +++ b/grade/tests/privacy_test.php @@ -390,12 +390,12 @@ public function test_get_users_in_context_grades_and_history() { $userlist = new \core_privacy\local\request\userlist($c1ctx, 'core_grades'); provider::get_users_in_context($userlist); $course1userids = [$u1->id, $u2->id, $u3->id, $u4->id]; - $this->assertEquals($course1userids, $userlist->get_userids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($course1userids, $userlist->get_userids()); $userlist = new \core_privacy\local\request\userlist($c2ctx, 'core_grades'); provider::get_users_in_context($userlist); $course2userids = [$u5->id, $u2->id]; - $this->assertEquals($course2userids, $userlist->get_userids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($course2userids, $userlist->get_userids()); $userlist = new \core_privacy\local\request\userlist($u2ctx, 'core_grades'); provider::get_users_in_context($userlist); diff --git a/group/tests/privacy_provider_test.php b/group/tests/privacy_provider_test.php index 3e8ff58a14f06..0f0e20c494caf 100644 --- a/group/tests/privacy_provider_test.php +++ b/group/tests/privacy_provider_test.php @@ -96,10 +96,9 @@ public function test_export_groups() { $exportedgroups = $data->groups; // User1 belongs to group1 and group2. - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$group1->name, $group2->name], - array_column($exportedgroups, 'name'), - '', 0.0, 10, true); + array_column($exportedgroups, 'name')); } /** @@ -295,7 +294,7 @@ public function test_delete_groups_for_all_users_deletes_cache() { $this->getDataGenerator()->create_group_member(array('userid' => $user1->id, 'groupid' => $group2->id)); $this->getDataGenerator()->create_group_member(array('userid' => $user2->id, 'groupid' => $group1->id)); - $this->assertEquals([[$group1->id, $group2->id]], groups_get_user_groups($course->id, $user1->id), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([[$group1->id, $group2->id]], groups_get_user_groups($course->id, $user1->id)); $this->assertEquals([[$group1->id]], groups_get_user_groups($course->id, $user2->id)); $coursecontext = context_course::instance($course->id); @@ -668,7 +667,7 @@ public function test_delete_groups_for_user_deletes_cache() { $this->getDataGenerator()->create_group_member(array('userid' => $user->id, 'groupid' => $group1->id)); $this->getDataGenerator()->create_group_member(array('userid' => $user->id, 'groupid' => $group2->id)); - $this->assertEquals([[$group1->id, $group2->id]], groups_get_user_groups($course->id, $user->id), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([[$group1->id, $group2->id]], groups_get_user_groups($course->id, $user->id)); $this->setUser($user); $coursecontext = context_course::instance($course->id); @@ -799,10 +798,9 @@ public function test_export_user_data() { $exportedgroups = $data->groups; // User1 belongs to group1 and group2. - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$group1->name, $group2->name], - array_column($exportedgroups, 'name'), - '', 0.0, 10, true); + array_column($exportedgroups, 'name')); } /** @@ -1080,9 +1078,8 @@ public function test_get_users_in_context() { // Only user1 and user2. User3 is not member of any group in course1. $this->assertCount(2, $userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$user1->id, $user2->id], - $userlist->get_userids(), - '', 0.0, 10, true); + $userlist->get_userids()); } } diff --git a/iplookup/tests/geoplugin_test.php b/iplookup/tests/geoplugin_test.php index 3ebe8b4fc7db1..491308e159f7b 100644 --- a/iplookup/tests/geoplugin_test.php +++ b/iplookup/tests/geoplugin_test.php @@ -51,8 +51,8 @@ public function test_ipv4() { $this->assertEquals('array', gettype($result)); $this->assertEquals('San Francisco', $result['city']); - $this->assertEquals(-122.3933, $result['longitude'], 'Coordinates are out of accepted tolerance', 0.01); - $this->assertEquals(37.7697, $result['latitude'], 'Coordinates are out of accepted tolerance', 0.01); + $this->assertEqualsWithDelta(-122.3933, $result['longitude'], 0.01, 'Coordinates are out of accepted tolerance'); + $this->assertEqualsWithDelta(37.7697, $result['latitude'], 0.01, 'Coordinates are out of accepted tolerance'); $this->assertNull($result['error']); $this->assertEquals('array', gettype($result['title'])); $this->assertEquals('San Francisco', $result['title'][0]); diff --git a/lib/ddl/tests/ddl_test.php b/lib/ddl/tests/ddl_test.php index 35526acdf4ebe..dd09cc6316c74 100644 --- a/lib/ddl/tests/ddl_test.php +++ b/lib/ddl/tests/ddl_test.php @@ -574,7 +574,7 @@ public function test_row_size_limits() { $id = $DB->insert_record('test_innodb', $data); $expected = (array)$data; $expected['id'] = (string)$id; - $this->assertEquals($expected, (array)$DB->get_record('test_innodb', array('id' => $id)), '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected, (array)$DB->get_record('test_innodb', array('id' => $id))); } catch (dml_exception $e) { // Give some nice error message when known problematic MySQL with InnoDB detected. if ($DB->get_dbfamily() === 'mysql') { @@ -607,7 +607,7 @@ public function test_row_size_limits() { $id = $DB->insert_record('test_innodb', $data); $expected = (array)$data; $expected['id'] = (string)$id; - $this->assertEquals($expected, (array)$DB->get_record('test_innodb', array('id' => $id)), '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected, (array)$DB->get_record('test_innodb', array('id' => $id))); } $dbman->drop_table($table); @@ -628,7 +628,7 @@ public function test_row_size_limits() { $id = $DB->insert_record('test_innodb', $data); $expected = (array)$data; $expected['id'] = (string)$id; - $this->assertEquals($expected, (array)$DB->get_record('test_innodb', array('id' => $id)), '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected, (array)$DB->get_record('test_innodb', array('id' => $id))); $dbman->drop_table($table); } diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index c2fc921bad024..bff9b970acf94 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -1410,7 +1410,7 @@ public function test_export_table_recordset() { $rids[] = $record->id; } $rs->close(); - $this->assertEquals($ids, $rids, '', 0, 0, true); + $this->assertEqualsCanonicalizing($ids, $rids); } public function test_get_records() { @@ -3847,7 +3847,7 @@ public function test_cast_char2real() { $this->assertSame('91.10', next($records)->name); // And verify we can operate with them without too much problem with at least 6 decimals scale accuracy. $sql = "SELECT AVG(" . $DB->sql_cast_char2real('name') . ") FROM {{$tablename}}"; - $this->assertEquals(37.44444443333333, (float)$DB->get_field_sql($sql), '', 1.0E-6); + $this->assertEqualsWithDelta(37.44444443333333, (float)$DB->get_field_sql($sql), 1.0E-6); // Casting text field. $sql = "SELECT * FROM {{$tablename}} WHERE ".$DB->sql_cast_char2real('nametext', true)." > res"; @@ -3862,7 +3862,7 @@ public function test_cast_char2real() { $this->assertSame('91.10', next($records)->nametext); // And verify we can operate with them without too much problem with at least 6 decimals scale accuracy. $sql = "SELECT AVG(" . $DB->sql_cast_char2real('nametext', true) . ") FROM {{$tablename}}"; - $this->assertEquals(37.44444443333333, (float)$DB->get_field_sql($sql), '', 1.0E-6); + $this->assertEqualsWithDelta(37.44444443333333, (float)$DB->get_field_sql($sql), 1.0E-6); // Check it works with values passed as param. $sql = "SELECT name FROM {{$tablename}} WHERE FLOOR(res - " . $DB->sql_cast_char2real(':param') . ") = 0"; diff --git a/lib/grade/tests/grade_item_test.php b/lib/grade/tests/grade_item_test.php index 5c0b46ba85dba..28b7f9c525cac 100644 --- a/lib/grade/tests/grade_item_test.php +++ b/lib/grade/tests/grade_item_test.php @@ -427,14 +427,14 @@ protected function sub_test_grade_item_rescale_grades_keep_percentage() { // Check that the grades were updated to match the grade item. $grade = $DB->get_record('grade_grades', array('id' => $gradeids[0])); - $this->assertEquals($gradeitem->grademax, $grade->rawgrademax, 'Max grade mismatch', 0.0001); - $this->assertEquals($gradeitem->grademin, $grade->rawgrademin, 'Min grade mismatch', 0.0001); - $this->assertEquals(6, $grade->finalgrade, 'Min grade mismatch', 0.0001); + $this->assertEqualsWithDelta($gradeitem->grademax, $grade->rawgrademax, 0.0001, 'Max grade mismatch'); + $this->assertEqualsWithDelta($gradeitem->grademin, $grade->rawgrademin, 0.0001, 'Min grade mismatch'); + $this->assertEqualsWithDelta(6, $grade->finalgrade, 0.0001, 'Min grade mismatch'); $grade = $DB->get_record('grade_grades', array('id' => $gradeids[1])); - $this->assertEquals($gradeitem->grademax, $grade->rawgrademax, 'Max grade mismatch', 0.0001); - $this->assertEquals($gradeitem->grademin, $grade->rawgrademin, 'Min grade mismatch', 0.0001); - $this->assertEquals(18, $grade->finalgrade, 'Min grade mismatch', 0.0001); + $this->assertEqualsWithDelta($gradeitem->grademax, $grade->rawgrademax, 0.0001, 'Max grade mismatch'); + $this->assertEqualsWithDelta($gradeitem->grademin, $grade->rawgrademin, 0.0001, 'Min grade mismatch'); + $this->assertEqualsWithDelta(18, $grade->finalgrade, 0.0001, 'Min grade mismatch'); } protected function sub_test_grade_item_set_locked() { diff --git a/lib/phpunit/tests/basic_test.php b/lib/phpunit/tests/basic_test.php index 9ef7e1d995b1e..df989ee6a77bf 100644 --- a/lib/phpunit/tests/basic_test.php +++ b/lib/phpunit/tests/basic_test.php @@ -72,7 +72,7 @@ public function test_assert_behaviour() { $this->assertNotEquals($a, $b); $this->assertNotEquals($a, $d); $this->assertEquals($a, $c); - $this->assertEquals($a, $b, '', 0, 10, true); + $this->assertEqualsCanonicalizing($a, $b); // Objects. $a = new stdClass(); diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 42d147a5dd8e5..a0f549cbf8006 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -676,13 +676,13 @@ public function test_get_roles_with_capability() { assign_capability('moodle/backup:backupcourse', CAP_PREVENT, $teacher->id, $frontcontext->id); $roles = get_roles_with_capability('moodle/backup:backupcourse'); - $this->assertEquals(array($teacher->id, $manager->id), array_keys($roles), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array($teacher->id, $manager->id), array_keys($roles), true); $roles = get_roles_with_capability('moodle/backup:backupcourse', CAP_ALLOW); - $this->assertEquals(array($manager->id), array_keys($roles), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array($manager->id), array_keys($roles), true); $roles = get_roles_with_capability('moodle/backup:backupcourse', null, $syscontext); - $this->assertEquals(array($manager->id), array_keys($roles), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array($manager->id), array_keys($roles), true); } /** @@ -762,7 +762,8 @@ public function test_get_all_roles() { $role = reset($allroles); $role = (array)$role; - $this->assertEquals(array('id', 'name', 'shortname', 'description', 'sortorder', 'archetype'), array_keys($role), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('id', 'name', 'shortname', 'description', 'sortorder', 'archetype'), + array_keys($role)); foreach ($allroles as $roleid => $role) { $this->assertEquals($role->id, $roleid); @@ -784,7 +785,7 @@ public function test_get_all_roles() { $role = reset($allroles); $role = (array)$role; - $this->assertEquals(array('id', 'name', 'shortname', 'description', 'sortorder', 'archetype', 'coursealias'), array_keys($role), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('id', 'name', 'shortname', 'description', 'sortorder', 'archetype', 'coursealias'), array_keys($role)); foreach ($allroles as $roleid => $role) { $this->assertEquals($role->id, $roleid); diff --git a/lib/tests/blocklib_test.php b/lib/tests/blocklib_test.php index c68ca54d59c0e..f15ce7b32ad7b 100644 --- a/lib/tests/blocklib_test.php +++ b/lib/tests/blocklib_test.php @@ -98,7 +98,7 @@ public function test_add_regions() { // Exercise SUT. $this->blockmanager->add_regions($regions, false); // Validate. - $this->assertEquals($regions, $this->blockmanager->get_regions(), '', 0, 10, true); + $this->assertEqualsCanonicalizing($regions, $this->blockmanager->get_regions()); } public function test_add_region_twice() { @@ -106,7 +106,7 @@ public function test_add_region_twice() { $this->blockmanager->add_region('a-region-name', false); $this->blockmanager->add_region('another-region', false); // Validate. - $this->assertEquals(array('a-region-name', 'another-region'), $this->blockmanager->get_regions(), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('a-region-name', 'another-region'), $this->blockmanager->get_regions()); } public function test_cannot_add_region_after_loaded() { @@ -142,7 +142,7 @@ public function test_add_custom_regions() { // Exercise SUT. $this->blockmanager->add_regions($regions); // Validate. - $this->assertEquals($regions, $this->blockmanager->get_regions(), '', 0, 10, true); + $this->assertEqualsCanonicalizing($regions, $this->blockmanager->get_regions()); $this->assertTrue(isset($SESSION->custom_block_regions)); $this->assertArrayHasKey('phpunit-block-test', $SESSION->custom_block_regions); $this->assertTrue(in_array('another-custom-region', $SESSION->custom_block_regions['phpunit-block-test'])); @@ -156,11 +156,9 @@ public function test_add_custom_region_twice() { $this->blockmanager->add_region('a-custom-region-name'); $this->blockmanager->add_region('another-custom-region'); // Validate. - $this->assertEquals( + $this->assertEqualsCanonicalizing( array('a-custom-region-name', 'another-custom-region'), - $this->blockmanager->get_regions(), - '', 0, 10, true - ); + $this->blockmanager->get_regions()); } /** @@ -198,17 +196,17 @@ public function test_cannot_change_default_region_after_loaded() { } public function test_matching_page_type_patterns() { - $this->assertEquals(array('site-index', 'site-index-*', 'site-*', '*'), - matching_page_type_patterns('site-index'), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('site-index', 'site-index-*', 'site-*', '*'), + matching_page_type_patterns('site-index')); - $this->assertEquals(array('mod-quiz-report-overview', 'mod-quiz-report-overview-*', 'mod-quiz-report-*', 'mod-quiz-*', 'mod-*', '*'), - matching_page_type_patterns('mod-quiz-report-overview'), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('mod-quiz-report-overview', 'mod-quiz-report-overview-*', 'mod-quiz-report-*', 'mod-quiz-*', 'mod-*', '*'), + matching_page_type_patterns('mod-quiz-report-overview')); - $this->assertEquals(array('mod-forum-view', 'mod-*-view', 'mod-forum-view-*', 'mod-forum-*', 'mod-*', '*'), - matching_page_type_patterns('mod-forum-view'), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('mod-forum-view', 'mod-*-view', 'mod-forum-view-*', 'mod-forum-*', 'mod-*', '*'), + matching_page_type_patterns('mod-forum-view')); - $this->assertEquals(array('mod-forum-index', 'mod-*-index', 'mod-forum-index-*', 'mod-forum-*', 'mod-*', '*'), - matching_page_type_patterns('mod-forum-index'), '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('mod-forum-index', 'mod-*-index', 'mod-forum-index-*', 'mod-forum-*', 'mod-*', '*'), + matching_page_type_patterns('mod-forum-index')); } protected function get_a_page_and_block_manager($regions, $context, $pagetype, $subpage = '') { diff --git a/lib/tests/filterlib_test.php b/lib/tests/filterlib_test.php index a2119642db971..62719022a3152 100644 --- a/lib/tests/filterlib_test.php +++ b/lib/tests/filterlib_test.php @@ -339,7 +339,7 @@ protected function remove_all_filters_from_config() { } private function assert_filter_list($expectedfilters, $filters) { - $this->assertEquals($expectedfilters, array_keys($filters), '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedfilters, array_keys($filters)); } public function test_globally_on_is_returned() { diff --git a/lib/tests/grouplib_test.php b/lib/tests/grouplib_test.php index 7f62f08cfbac8..b057d5060ae9f 100644 --- a/lib/tests/grouplib_test.php +++ b/lib/tests/grouplib_test.php @@ -1109,10 +1109,9 @@ public function test_groups_get_all_groups_in_grouping_with_members() { // Test without userid. $groups = groups_get_all_groups($course1->id, null, $c1grouping1->id, 'g.*', true); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$c1group1->id, $c1group2->id], - array_keys($groups), - '', 0.0, 10, true + array_keys($groups) ); $this->assertEquals( [$c1user1->id => $c1user1->id, $c12user1->id => $c12user1->id], @@ -1127,10 +1126,9 @@ public function test_groups_get_all_groups_in_grouping_with_members() { $groups = groups_get_all_groups($course1->id, $c1user1->id, $c1grouping1->id, 'g.*', true); $this->assertEquals([$c1group1->id], array_keys($groups)); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$c1user1->id, $c12user1->id], - $groups[$c1group1->id]->members, - '', 0.0, 10, true + $groups[$c1group1->id]->members ); } @@ -1847,12 +1845,12 @@ public function test_groups_get_activity_shared_group_members() { // Retrieve users sharing groups with user1. $members = groups_get_activity_shared_group_members($cm, $user1->id); $this->assertCount(2, $members); - $this->assertEquals([$user1->id, $user2->id], array_keys($members), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$user1->id, $user2->id], array_keys($members)); // Retrieve users sharing groups with user2. $members = groups_get_activity_shared_group_members($cm, $user2->id); $this->assertCount(2, $members); - $this->assertEquals([$user1->id, $user2->id], array_keys($members), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$user1->id, $user2->id], array_keys($members)); // Retrieve users sharing groups with user3. $members = groups_get_activity_shared_group_members($cm, $user3->id); @@ -1881,6 +1879,6 @@ public function test_groups_get_activity_shared_group_members() { $generator->create_group_member(array('groupid' => $group3->id, 'userid' => $user1->id)); $members = groups_get_activity_shared_group_members($cm, $user1->id); $this->assertCount(2, $members); // Now I see members of group 3. - $this->assertEquals([$user1->id, $user3->id], array_keys($members), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$user1->id, $user3->id], array_keys($members)); } } diff --git a/lib/tests/mathslib_test.php b/lib/tests/mathslib_test.php index 999217590edef..b1e71f7a4e34e 100644 --- a/lib/tests/mathslib_test.php +++ b/lib/tests/mathslib_test.php @@ -295,19 +295,19 @@ public function test_rounding_function() { public function test_scientific_notation() { $formula = new calc_formula('=10e10'); - $this->assertEquals(1e11, $formula->evaluate(), '', 1e11*1e-15); + $this->assertEqualsWithDelta(1e11, $formula->evaluate(), 1e11 * 1e-15); $formula = new calc_formula('=10e-10'); - $this->assertEquals(1e-9, $formula->evaluate(), '', 1e11*1e-15); + $this->assertEqualsWithDelta(1e-9, $formula->evaluate(), 1e11 * 1e-15); $formula = new calc_formula('=10e+10'); - $this->assertEquals(1e11, $formula->evaluate(), '', 1e11*1e-15); + $this->assertEqualsWithDelta(1e11, $formula->evaluate(), 1e11 * 1e-15); $formula = new calc_formula('=10e10*5'); - $this->assertEquals(5e11, $formula->evaluate(), '', 1e11*1e-15); + $this->assertEqualsWithDelta(5e11, $formula->evaluate(), 1e11 * 1e-15); $formula = new calc_formula('=10e10^2'); - $this->assertEquals(1e22, $formula->evaluate(), '', 1e22*1e-15); + $this->assertEqualsWithDelta(1e22, $formula->evaluate(), 1e22 * 1e-15); } public function test_rand_float() { diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 68dd0e0841762..ff52d2c1e18d3 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -3957,7 +3957,7 @@ public function test_complex_random_string() { $this->assertRegExp('/^[' . $pool . ']+$/', $result); $result = complex_random_string(); - $this->assertEquals(28, strlen($result), '', 4); // Expected length is 24 - 32. + $this->assertEqualsWithDelta(28, strlen($result), 4); // Expected length is 24 - 32. $this->assertRegExp('/^[' . $pool . ']+$/', $result); $this->assertDebuggingNotCalled(); diff --git a/lib/tests/session_manager_test.php b/lib/tests/session_manager_test.php index a71d1acee6af0..968dafb9d42cf 100644 --- a/lib/tests/session_manager_test.php +++ b/lib/tests/session_manager_test.php @@ -64,7 +64,7 @@ public function test_init_empty_session() { $this->assertSame($GLOBALS['SESSION'], $SESSION); $this->assertInstanceOf('stdClass', $USER); - $this->assertEquals(array('id' => 0, 'mnethostid' => 1), (array)$USER, '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('id' => 0, 'mnethostid' => 1), (array)$USER); $this->assertSame($GLOBALS['USER'], $_SESSION['USER']); $this->assertSame($GLOBALS['USER'], $USER); @@ -154,7 +154,7 @@ public function test_terminate_current() { $this->assertSame($GLOBALS['SESSION'], $SESSION); $this->assertInstanceOf('stdClass', $USER); - $this->assertEquals(array('id' => 0, 'mnethostid' => 1), (array)$USER, '', 0, 10, true); + $this->assertEqualsCanonicalizing(array('id' => 0, 'mnethostid' => 1), (array)$USER); $this->assertSame($GLOBALS['USER'], $_SESSION['USER']); $this->assertSame($GLOBALS['USER'], $USER); } diff --git a/lib/tests/time_splittings_test.php b/lib/tests/time_splittings_test.php index 646bbf48d3d0e..224fbeb8ba1f2 100644 --- a/lib/tests/time_splittings_test.php +++ b/lib/tests/time_splittings_test.php @@ -247,13 +247,13 @@ public function test_periodic() { $ranges = $pastweek->get_most_recent_prediction_range(); $range = reset($ranges); $this->assertEquals(3, key($ranges)); - $this->assertEquals(time(), $range['time'], '', 1); + $this->assertEqualsWithDelta(time(), $range['time'], 1); // 1 second delta for the start just in case a second passes between the set_analysable call // and this checking below. $time = new \DateTime(); $time->sub($pastweek->periodicity()); - $this->assertEquals($time->getTimestamp(), $range['start'], '', 1.0); - $this->assertEquals(time(), $range['end'], '', 1); + $this->assertEqualsWithDelta($time->getTimestamp(), $range['start'], 1.0); + $this->assertEqualsWithDelta(time(), $range['end'], 1); $starttime = time(); @@ -264,8 +264,8 @@ public function test_periodic() { $ranges = $upcomingweek->get_all_ranges(); $this->assertEquals(1, count($ranges)); $range = reset($ranges); - $this->assertEquals(time(), $range['time'], '', 1); - $this->assertEquals(time(), $range['start'], '', 1); + $this->assertEqualsWithDelta(time(), $range['time'], 1); + $this->assertEqualsWithDelta(time(), $range['start'], 1); $this->assertGreaterThan(time(), $range['end']); $this->assertCount(0, $upcomingweek->get_training_ranges()); @@ -273,8 +273,8 @@ public function test_periodic() { $ranges = $upcomingweek->get_most_recent_prediction_range(); $range = reset($ranges); $this->assertEquals(0, key($ranges)); - $this->assertEquals(time(), $range['time'], '', 1); - $this->assertEquals(time(), $range['start'], '', 1); + $this->assertEqualsWithDelta(time(), $range['time'], 1); + $this->assertEqualsWithDelta(time(), $range['start'], 1); $this->assertGreaterThanOrEqual($starttime, $range['time']); $this->assertGreaterThanOrEqual($starttime, $range['start']); $this->assertGreaterThan(time(), $range['end']); diff --git a/message/tests/privacy_provider_test.php b/message/tests/privacy_provider_test.php index 5c0ad089648e9..07e20370e94af 100644 --- a/message/tests/privacy_provider_test.php +++ b/message/tests/privacy_provider_test.php @@ -1631,7 +1631,7 @@ public function test_add_conversations_in_context() { // Test for users with any group conversation in course1. provider::add_conversations_in_context($userlist1, $component, $itemtype); $this->assertCount(3, $userlist1); - $this->assertEquals([$user1->id, $user2->id, $user3->id], $userlist1->get_userids(), '', 0, 10, true); + $this->assertEqualsCanonicalizing([$user1->id, $user2->id, $user3->id], $userlist1->get_userids()); // Test for users with any group conversation in course2. $userlist2 = new \core_privacy\local\request\userlist($coursecontext2, 'core_message'); diff --git a/mod/data/tests/lib_test.php b/mod/data/tests/lib_test.php index c4ae8328cab78..88d71666ef511 100644 --- a/mod/data/tests/lib_test.php +++ b/mod/data/tests/lib_test.php @@ -1311,7 +1311,7 @@ public function test_check_updates_since() { // Check we received the entries updated. $updates = data_check_updates_since($cm, $onehourago); $this->assertTrue($updates->entries->updated); - $this->assertEquals([$datarecor1did, $datarecor2did], $updates->entries->itemids, '', 0, 10, true); + $this->assertEqualsCanonicalizing([$datarecor1did, $datarecor2did], $updates->entries->itemids); } public function test_data_core_calendar_provide_event_action_in_hidden_section() { diff --git a/mod/glossary/tests/external_test.php b/mod/glossary/tests/external_test.php index d25ce90f8aabd..18bbcc8fe8015 100644 --- a/mod/glossary/tests/external_test.php +++ b/mod/glossary/tests/external_test.php @@ -914,7 +914,7 @@ public function test_get_entries_by_term() { // Compare ids, ignore ordering of array, using canonicalize parameter of assertEquals. $expected = array($e1->id, $e2->id); $actual = array($return['entries'][0]['id'], $return['entries'][1]['id']); - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); // Compare rawnames of all expected tags, ignore ordering of array, using canonicalize parameter of assertEquals. $expected = array('Cats', 'Dogs'); // Only $e1 has 2 tags. $actual = array(); // Accumulate all tags returned. @@ -923,7 +923,7 @@ public function test_get_entries_by_term() { $actual[] = $tag['rawname']; } } - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); // Search alias. $return = mod_glossary_external::get_entries_by_term($g1->id, 'dog', 0, 20, array('includenotapproved' => false)); @@ -934,7 +934,7 @@ public function test_get_entries_by_term() { // Compare ids, ignore ordering of array, using canonicalize parameter of assertEquals. $expected = array($e2->id, $e3->id); $actual = array($return['entries'][0]['id'], $return['entries'][1]['id']); - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); // Search including not approved. $return = mod_glossary_external::get_entries_by_term($g1->id, 'dog', 0, 20, array('includenotapproved' => true)); @@ -944,7 +944,7 @@ public function test_get_entries_by_term() { // Compare ids, ignore ordering of array, using canonicalize parameter of assertEquals. $expected = array($e4->id, $e2->id, $e3->id); $actual = array($return['entries'][0]['id'], $return['entries'][1]['id'], $return['entries'][2]['id']); - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); // Pagination. $return = mod_glossary_external::get_entries_by_term($g1->id, 'dog', 0, 1, array('includenotapproved' => true)); diff --git a/mod/quiz/report/statistics/tests/statistics_test.php b/mod/quiz/report/statistics/tests/statistics_test.php index 1ab74e87512e8..d4bfeaf6dc34b 100644 --- a/mod/quiz/report/statistics/tests/statistics_test.php +++ b/mod/quiz/report/statistics/tests/statistics_test.php @@ -144,7 +144,7 @@ public function qstats_q_fields($fieldname, $values, $multiplier=1) { foreach ($this->qstats->get_all_slots() as $slot) { $value = array_shift($values); if ($value !== null) { - $this->assertEquals($value, $this->qstats->for_slot($slot)->{$fieldname} * $multiplier, '', 1E-6); + $this->assertEqualsWithDelta($value, $this->qstats->for_slot($slot)->{$fieldname} * $multiplier, 1E-6); } else { $this->assertEquals($value, $this->qstats->for_slot($slot)->{$fieldname} * $multiplier); } diff --git a/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php b/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php index 53cb2170c7ea3..da80848a03672 100644 --- a/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php +++ b/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php @@ -151,7 +151,7 @@ protected function assert_stat_equals($expected, $questionstats, $slot, $subqnam $precision = 1e-6; } $delta = abs($expected) * $precision; - $this->assertEquals((float)$expected, $actual, $message, $delta); + $this->assertEqualsWithDelta((float)$expected, $actual, $delta, $message); } else { $this->assertEquals($expected, $actual, $message); } @@ -273,7 +273,7 @@ protected function check_variants_count_for_quiz_00($questions, $questionstats, $variantsnos = $analysis->get_variant_nos(); if (isset($expectedvariantcounts[$slot])) { // Compare contents, ignore ordering of array, using canonicalize parameter of assertEquals. - $this->assertEquals(array_keys($expectedvariantcounts[$slot]), $variantsnos, '', 0, 10, true); + $this->assertEqualsCanonicalizing(array_keys($expectedvariantcounts[$slot]), $variantsnos); } else { $this->assertEquals(array(1), $variantsnos); } @@ -310,12 +310,9 @@ protected function check_variants_count_for_quiz_00($questions, $questionstats, if (isset($expectedvariantcounts[$slot])) { // If we know how many attempts there are at each variant we can check // that we have counted the correct amount of responses for each variant. - $this->assertEquals($expectedvariantcounts[$slot], + $this->assertEqualsCanonicalizing($expectedvariantcounts[$slot], $totalpervariantno, - "Totals responses do not add up in response analysis for slot {$slot}.", - 0, - 10, - true); + "Totals responses do not add up in response analysis for slot {$slot}."); } else { $this->assertEquals(25, array_sum($totalpervariantno), @@ -351,7 +348,7 @@ protected function check_quiz_stats_for_quiz_00($quizstats) { ); foreach ($quizstatsexpected as $statname => $statvalue) { - $this->assertEquals($statvalue, $quizstats->$statname, $quizstats->$statname, abs($statvalue) * 1.5e-5); + $this->assertEqualsWithDelta($statvalue, $quizstats->$statname, abs($statvalue) * 1.5e-5, $quizstats->$statname); } } diff --git a/mod/quiz/tests/local_structure_slot_random_test.php b/mod/quiz/tests/local_structure_slot_random_test.php index a9c1cd5fbfdab..618726206ebdd 100644 --- a/mod/quiz/tests/local_structure_slot_random_test.php +++ b/mod/quiz/tests/local_structure_slot_random_test.php @@ -400,14 +400,13 @@ public function test_insert() { $this->assertEquals(1, $quizslot->maxmark); $this->assertCount(2, $quizslottags); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ ['tagid' => $footag->id, 'tagname' => $footag->name], ['tagid' => $bartag->id, 'tagname' => $bartag->name] ], array_map(function($slottag) { return ['tagid' => $slottag->tagid, 'tagname' => $slottag->tagname]; - }, $quizslottags), - '', 0.0, 10, true); + }, $quizslottags)); } -} \ No newline at end of file +} diff --git a/mod/quiz/tests/locallib_test.php b/mod/quiz/tests/locallib_test.php index 453d9d121cc66..7b9ee84217d9c 100644 --- a/mod/quiz/tests/locallib_test.php +++ b/mod/quiz/tests/locallib_test.php @@ -519,15 +519,14 @@ public function test_quiz_retrieve_slot_tags() { $slotid = $DB->get_field('quiz_slots', 'id', array('quizid' => $quiz->id, 'slot' => 2)); $slottags = quiz_retrieve_slot_tags($slotid); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ ['tagid' => $tags['foo']->id, 'tagname' => $tags['foo']->name], ['tagid' => $tags['bar']->id, 'tagname' => $tags['bar']->name] ], array_map(function($slottag) { return ['tagid' => $slottag->tagid, 'tagname' => $slottag->tagname]; - }, $slottags), - '', 0.0, 10, true); + }, $slottags)); } public function test_quiz_retrieve_slot_tags_with_removed_tag() { @@ -546,15 +545,14 @@ public function test_quiz_retrieve_slot_tags_with_removed_tag() { core_tag_tag::delete_tags([$tags['foo']->id]); $slottags = quiz_retrieve_slot_tags($slotid); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ ['tagid' => null, 'tagname' => $tags['foo']->name], ['tagid' => $tags['bar']->id, 'tagname' => $tags['bar']->name] ], array_map(function($slottag) { return ['tagid' => $slottag->tagid, 'tagname' => $slottag->tagname]; - }, $slottags), - '', 0.0, 10, true); + }, $slottags)); } public function test_quiz_retrieve_slot_tags_for_standard_question() { @@ -584,7 +582,7 @@ public function test_quiz_retrieve_slot_tag_ids() { $slotid = $DB->get_field('quiz_slots', 'id', array('quizid' => $quiz->id, 'slot' => 2)); $tagids = quiz_retrieve_slot_tag_ids($slotid); - $this->assertEquals([$tags['foo']->id, $tags['bar']->id], $tagids, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$tags['foo']->id, $tags['bar']->id], $tagids); } public function test_quiz_retrieve_slot_tag_ids_for_standard_question() { @@ -599,7 +597,7 @@ public function test_quiz_retrieve_slot_tag_ids_for_standard_question() { $slotid = $DB->get_field('quiz_slots', 'id', array('quizid' => $quiz->id, 'slot' => 1)); $tagids = quiz_retrieve_slot_tag_ids($slotid); - $this->assertEquals([], $tagids, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([], $tagids); } /** diff --git a/mod/quiz/tests/privacy_provider_test.php b/mod/quiz/tests/privacy_provider_test.php index 40c533f14e541..74ccd4710132a 100644 --- a/mod/quiz/tests/privacy_provider_test.php +++ b/mod/quiz/tests/privacy_provider_test.php @@ -489,10 +489,9 @@ public function test_get_users_in_context() { // Fetch users - user1 and user2 should be returned. $userlist = new \core_privacy\local\request\userlist($context, 'mod_quiz'); \mod_quiz\privacy\provider::get_users_in_context($userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$user->id, $anotheruser->id], - $userlist->get_userids(), - '', 0.0, 10, true); + $userlist->get_userids()); } /** diff --git a/mod/quiz/tests/tags_test.php b/mod/quiz/tests/tags_test.php index 094abb29aedc9..7781f00ff74c9 100644 --- a/mod/quiz/tests/tags_test.php +++ b/mod/quiz/tests/tags_test.php @@ -84,14 +84,13 @@ public function test_restore_random_question_by_tag() { $this->assertNotFalse($tag3); $slottags = quiz_retrieve_slot_tags($question->slotid); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [ ['tagid' => $tag2->id, 'tagname' => $tag2->name] ], array_map(function($tag) { return ['tagid' => $tag->tagid, 'tagname' => $tag->tagname]; - }, $slottags), - '', 0.0, 10, true + }, $slottags) ); $defaultcategory = question_get_default_category(context_course::instance($newcourseid)->id); diff --git a/mod/wiki/tests/lib_test.php b/mod/wiki/tests/lib_test.php index 172ebf7563490..a4099ad622e23 100644 --- a/mod/wiki/tests/lib_test.php +++ b/mod/wiki/tests/lib_test.php @@ -468,7 +468,7 @@ public function test_wiki_get_visible_subwikis_without_groups() { $expectedsubwikis[] = $teachersubwiki; $result = wiki_get_visible_subwikis($indwiki); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); // Compare without order. + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); // Compare without order. } /** @@ -544,7 +544,7 @@ public function test_wiki_get_visible_subwikis_with_groups_collaborative() { // Check that he can get subwikis from both groups in collaborative wiki with visible groups, and also all participants. $expectedsubwikis = array($swviscolallparts, $swviscolg1, $swviscolg2); $result = wiki_get_visible_subwikis($wikiviscol); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); // Now test it as a teacher. No need to check visible groups wikis because the result is the same as student. $this->setUser($teacher); @@ -552,7 +552,7 @@ public function test_wiki_get_visible_subwikis_with_groups_collaborative() { // Check that he can get the subwikis from all the groups in collaborative wiki with separate groups. $expectedsubwikis = array($swsepcolg1, $swsepcolg2, $swsepcolallparts); $result = wiki_get_visible_subwikis($wikisepcol); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); } /** @@ -639,12 +639,12 @@ public function test_wiki_get_visible_subwikis_with_groups_individual() { // Check that student can get the subwikis from his group in individual wiki with separate groups. $expectedsubwikis = array($swsepindg1s1, $swsepindg1s2); $result = wiki_get_visible_subwikis($wikisepind); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); // Check that he can get subwikis from all users and groups in individual wiki with visible groups. $expectedsubwikis = array($swvisindg1s1, $swvisindg1s2, $swvisindg2s2, $swvisindg2s3, $swvisindteacher); $result = wiki_get_visible_subwikis($wikivisind); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); // Now test it as a teacher. No need to check visible groups wikis because the result is the same as student. $this->setUser($teacher); @@ -652,7 +652,7 @@ public function test_wiki_get_visible_subwikis_with_groups_individual() { // Check that teacher can get the subwikis from all the groups in individual wiki with separate groups. $expectedsubwikis = array($swsepindg1s1, $swsepindg1s2, $swsepindg2s2, $swsepindg2s3, $swsepindteacher); $result = wiki_get_visible_subwikis($wikisepind); - $this->assertEquals($expectedsubwikis, $result, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expectedsubwikis, $result); } public function test_mod_wiki_get_tagged_pages() { diff --git a/mod/wiki/tests/privacy_test.php b/mod/wiki/tests/privacy_test.php index e28f6db15880d..b4c98ba4a65fb 100644 --- a/mod/wiki/tests/privacy_test.php +++ b/mod/wiki/tests/privacy_test.php @@ -247,26 +247,26 @@ public function test_get_contexts_for_userid() { // Get contexts for the first user. $contextids = provider::get_contexts_for_userid($this->users[1]->id)->get_contextids(); - $this->assertEquals([ + $this->assertEqualsCanonicalizing([ $this->contexts[1]->id, $this->contexts[2]->id, - ], $contextids, '', 0.0, 10, true); + ], $contextids); // Get contexts for the second user. $contextids = provider::get_contexts_for_userid($this->users[2]->id)->get_contextids(); - $this->assertEquals([ + $this->assertEqualsCanonicalizing([ $this->contexts[1]->id, $this->contexts[2]->id, $this->contexts[3]->id, - ], $contextids, '', 0.0, 10, true); + ], $contextids); // Get contexts for the third user. $contextids = provider::get_contexts_for_userid($this->users[3]->id)->get_contextids(); - $this->assertEquals([ + $this->assertEqualsCanonicalizing([ $this->contexts[1]->id, $this->contexts[2]->id, $this->contexts[3]->id, - ], $contextids, '', 0.0, 10, true); + ], $contextids); } /** @@ -361,7 +361,7 @@ public function test_export_user_data1() { // There is one file that was used in this user's contents - "Dog face.jpg" and one file in page cachedcontents. $files = writer::with_context($this->contexts[1])->get_files([$this->subwikis[1]]); - $this->assertEquals(['Dog jump.jpg', 'Hamster.jpg'], array_keys($files), '', 0, 10, true); + $this->assertEqualsCanonicalizing(['Dog jump.jpg', 'Hamster.jpg'], array_keys($files)); // Second (individual) wiki for the first user, two pages are returned for this user's subwiki. $data = writer::with_context($this->contexts[2])->get_related_data([$this->subwikis[21]]); diff --git a/mod/workshop/tests/privacy_provider_test.php b/mod/workshop/tests/privacy_provider_test.php index 7a093845aa848..fccbbb4240db2 100644 --- a/mod/workshop/tests/privacy_provider_test.php +++ b/mod/workshop/tests/privacy_provider_test.php @@ -189,19 +189,19 @@ public function test_get_contexts_for_userid() { // Student1 has data in workshop11 (author + self reviewer), workshop12 (author) and workshop21 (reviewer). $contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student1->id); $this->assertInstanceOf(\core_privacy\local\request\contextlist::class, $contextlist); - $this->assertEquals([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids()); // Student2 has data in workshop11 (reviewer), workshop12 (reviewer) and workshop21 (author). $contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student2->id); - $this->assertEquals([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids()); // Student3 has data in workshop11 (reviewer). $contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student3->id); - $this->assertEquals([$context11->id], $contextlist->get_contextids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$context11->id], $contextlist->get_contextids()); // Teacher4 has data in workshop12 (gradeoverby) and workshop21 (gradinggradeoverby). $contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->teacher4->id); - $this->assertEquals([$context21->id, $context12->id], $contextlist->get_contextids(), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing([$context21->id, $context12->id], $contextlist->get_contextids()); } /** @@ -226,7 +226,7 @@ public function test_get_users_in_context() { $this->student3->id, // Student3 has data in workshop11 (reviewer). ]; $actual11 = $userlist11->get_userids(); - $this->assertEquals($expected11, $actual11, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected11, $actual11); // Users in the workshop12. $userlist12 = new \core_privacy\local\request\userlist($context12, 'mod_workshop'); @@ -237,7 +237,7 @@ public function test_get_users_in_context() { $this->teacher4->id, // Teacher4 has data in workshop12 (gradeoverby). ]; $actual12 = $userlist12->get_userids(); - $this->assertEquals($expected12, $actual12, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected12, $actual12); // Users in the workshop21. $userlist21 = new \core_privacy\local\request\userlist($context21, 'mod_workshop'); @@ -248,7 +248,7 @@ public function test_get_users_in_context() { $this->teacher4->id, // Teacher4 has data in workshop21 (gradinggradeoverby). ]; $actual21 = $userlist21->get_userids(); - $this->assertEquals($expected21, $actual21, '', 0, 10, true); + $this->assertEqualsCanonicalizing($expected21, $actual21); } /** diff --git a/question/behaviour/adaptive/tests/walkthrough_test.php b/question/behaviour/adaptive/tests/walkthrough_test.php index 9158ac3382c35..282d49a2de591 100644 --- a/question/behaviour/adaptive/tests/walkthrough_test.php +++ b/question/behaviour/adaptive/tests/walkthrough_test.php @@ -181,7 +181,7 @@ public function test_adaptive_multichoice() { $this->get_contains_partcorrect_expectation()); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals($autogradedstep->get_fraction(), 1, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), 1, 0.0000001); } public function test_adaptive_multichoice2() { diff --git a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php index 49d5a6619fc1b..62cb7da15f93e 100644 --- a/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php +++ b/question/behaviour/adaptivenopenalty/tests/walkthrough_test.php @@ -163,7 +163,7 @@ public function test_multichoice() { $this->get_contains_partcorrect_expectation()); $autogradedstep = $this->get_step($this->get_step_count() - 3); - $this->assertEquals($autogradedstep->get_fraction(), 1, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), 1, 0.0000001); } public function test_multichoice2() { diff --git a/question/behaviour/deferredcbm/tests/question_cbm_test.php b/question/behaviour/deferredcbm/tests/question_cbm_test.php index 16d0d39ced9ca..20fc6fc71af4d 100644 --- a/question/behaviour/deferredcbm/tests/question_cbm_test.php +++ b/question/behaviour/deferredcbm/tests/question_cbm_test.php @@ -40,17 +40,17 @@ class qbehaviour_deferredcbm_cbm_test extends basic_testcase { public function test_adjust_fraction() { - $this->assertEquals( 1, question_cbm::adjust_fraction( 1, question_cbm::LOW), '', 0.0000001); - $this->assertEquals( 2, question_cbm::adjust_fraction( 1, question_cbm::MED), '', 0.0000001); - $this->assertEquals( 3, question_cbm::adjust_fraction( 1, question_cbm::HIGH), '', 0.0000001); - $this->assertEquals( 0, question_cbm::adjust_fraction( 0, question_cbm::LOW), '', 0.0000001); - $this->assertEquals(-2, question_cbm::adjust_fraction( 0, question_cbm::MED), '', 0.0000001); - $this->assertEquals(-6, question_cbm::adjust_fraction( 0, question_cbm::HIGH), '', 0.0000001); - $this->assertEquals( 0.5, question_cbm::adjust_fraction( 0.5, question_cbm::LOW), '', 0.0000001); - $this->assertEquals( 1, question_cbm::adjust_fraction( 0.5, question_cbm::MED), '', 0.0000001); - $this->assertEquals( 1.5, question_cbm::adjust_fraction( 0.5, question_cbm::HIGH), '', 0.0000001); - $this->assertEquals( 0, question_cbm::adjust_fraction(-0.25, question_cbm::LOW), '', 0.0000001); - $this->assertEquals(-2, question_cbm::adjust_fraction(-0.25, question_cbm::MED), '', 0.0000001); - $this->assertEquals(-6, question_cbm::adjust_fraction(-0.25, question_cbm::HIGH), '', 0.0000001); + $this->assertEqualsWithDelta( 1, question_cbm::adjust_fraction( 1, question_cbm::LOW), 0.0000001); + $this->assertEqualsWithDelta( 2, question_cbm::adjust_fraction( 1, question_cbm::MED), 0.0000001); + $this->assertEqualsWithDelta( 3, question_cbm::adjust_fraction( 1, question_cbm::HIGH), 0.0000001); + $this->assertEqualsWithDelta( 0, question_cbm::adjust_fraction( 0, question_cbm::LOW), 0.0000001); + $this->assertEqualsWithDelta(-2, question_cbm::adjust_fraction( 0, question_cbm::MED), 0.0000001); + $this->assertEqualsWithDelta(-6, question_cbm::adjust_fraction( 0, question_cbm::HIGH), 0.0000001); + $this->assertEqualsWithDelta( 0.5, question_cbm::adjust_fraction( 0.5, question_cbm::LOW), 0.0000001); + $this->assertEqualsWithDelta( 1, question_cbm::adjust_fraction( 0.5, question_cbm::MED), 0.0000001); + $this->assertEqualsWithDelta( 1.5, question_cbm::adjust_fraction( 0.5, question_cbm::HIGH), 0.0000001); + $this->assertEqualsWithDelta( 0, question_cbm::adjust_fraction(-0.25, question_cbm::LOW), 0.0000001); + $this->assertEqualsWithDelta(-2, question_cbm::adjust_fraction(-0.25, question_cbm::MED), 0.0000001); + $this->assertEqualsWithDelta(-6, question_cbm::adjust_fraction(-0.25, question_cbm::HIGH), 0.0000001); } } diff --git a/question/behaviour/deferredcbm/tests/walkthrough_test.php b/question/behaviour/deferredcbm/tests/walkthrough_test.php index b139c96a6d210..c961e8b41f1fb 100644 --- a/question/behaviour/deferredcbm/tests/walkthrough_test.php +++ b/question/behaviour/deferredcbm/tests/walkthrough_test.php @@ -113,7 +113,7 @@ public function test_deferred_cbm_truefalse_high_certainty() { $this->check_current_state(question_state::$mangrright); $this->check_current_mark(5); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals(-6, $autogradedstep->get_fraction(), '', 0.0000001); + $this->assertEqualsWithDelta(-6, $autogradedstep->get_fraction(), 0.0000001); } public function test_deferred_cbm_truefalse_low_certainty() { diff --git a/question/behaviour/deferredfeedback/tests/walkthrough_test.php b/question/behaviour/deferredfeedback/tests/walkthrough_test.php index c170aa4f522ed..18bfbe2d9226b 100644 --- a/question/behaviour/deferredfeedback/tests/walkthrough_test.php +++ b/question/behaviour/deferredfeedback/tests/walkthrough_test.php @@ -110,7 +110,7 @@ public function test_deferredfeedback_feedback_truefalse() { $this->check_current_mark(1); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals($autogradedstep->get_fraction(), 0, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), 0, 0.0000001); } public function test_deferredfeedback_feedback_multichoice_single() { diff --git a/question/behaviour/immediatecbm/tests/walkthrough_test.php b/question/behaviour/immediatecbm/tests/walkthrough_test.php index 71d8b717d5773..f0e1890f371d6 100644 --- a/question/behaviour/immediatecbm/tests/walkthrough_test.php +++ b/question/behaviour/immediatecbm/tests/walkthrough_test.php @@ -130,7 +130,7 @@ public function test_immediatecbm_feedback_multichoice_right() { $this->get_contains_partcorrect_expectation()); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals($autogradedstep->get_fraction(), -2, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), -2, 0.0000001); } public function test_immediatecbm_feedback_multichoice_try_to_submit_blank() { diff --git a/question/behaviour/immediatefeedback/tests/walkthrough_test.php b/question/behaviour/immediatefeedback/tests/walkthrough_test.php index b95c20430b4fe..93953b4f0c5da 100644 --- a/question/behaviour/immediatefeedback/tests/walkthrough_test.php +++ b/question/behaviour/immediatefeedback/tests/walkthrough_test.php @@ -137,7 +137,7 @@ public function test_immediatefeedback_feedback_multichoice_right() { $this->get_contains_partcorrect_expectation()); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals($autogradedstep->get_fraction(), -0.3333333, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), -0.3333333, 0.0000001); } public function test_immediatefeedback_feedback_multichoice_try_to_submit_blank() { diff --git a/question/behaviour/interactive/tests/walkthrough_test.php b/question/behaviour/interactive/tests/walkthrough_test.php index 2f182c556ce66..ec21240f1c006 100644 --- a/question/behaviour/interactive/tests/walkthrough_test.php +++ b/question/behaviour/interactive/tests/walkthrough_test.php @@ -176,7 +176,7 @@ public function test_interactive_feedback_multichoice_right() { $this->get_contains_partcorrect_expectation()); $autogradedstep = $this->get_step($this->get_step_count() - 2); - $this->assertEquals($autogradedstep->get_fraction(), 0.6666667, '', 0.0000001); + $this->assertEqualsWithDelta($autogradedstep->get_fraction(), 0.6666667, 0.0000001); } public function test_interactive_finish_when_try_again_showing() { diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index 733efd779d1c5..b9bcfa4fe252c 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -898,8 +898,8 @@ protected function check_current_mark($mark) { // so explicity check not null in this case. $this->assertNotNull($this->quba->get_question_mark($this->slot)); } - $this->assertEquals($mark, $this->quba->get_question_mark($this->slot), - 'Expected mark and actual mark differ.', 0.000001); + $this->assertEqualsWithDelta($mark, $this->quba->get_question_mark($this->slot), + 0.000001, 'Expected mark and actual mark differ.'); } } diff --git a/question/engine/tests/questionattemptstep_test.php b/question/engine/tests/questionattemptstep_test.php index 9c55790701d3a..b7a73ab0d46af 100644 --- a/question/engine/tests/questionattemptstep_test.php +++ b/question/engine/tests/questionattemptstep_test.php @@ -112,7 +112,7 @@ public function test_get_submitted_data() { public function test_constructor_default_params() { global $USER; $step = new question_attempt_step(); - $this->assertEquals(time(), $step->get_timecreated(), '', 5); + $this->assertEquals(time(), $step->get_timecreated(), 5); $this->assertEquals($USER->id, $step->get_user_id()); $this->assertEquals(array(), $step->get_qt_data()); $this->assertEquals(array(), $step->get_behaviour_data()); diff --git a/question/engine/tests/unitofwork_test.php b/question/engine/tests/unitofwork_test.php index af86f114e422d..e7ee5579e19bb 100644 --- a/question/engine/tests/unitofwork_test.php +++ b/question/engine/tests/unitofwork_test.php @@ -363,7 +363,7 @@ public function test_move_question_then_move_again() { public function test_set_max_mark() { $this->quba->set_max_mark($this->slot, 6.0); - $this->assertEquals(4.0, $this->quba->get_total_mark(), '', 0.0000005); + $this->assertEqualsWithDelta(4.0, $this->quba->get_total_mark(), 0.0000005); $this->assertEquals(0, count($this->observer->get_attempts_added())); diff --git a/question/tests/privacy_provider_test.php b/question/tests/privacy_provider_test.php index 50ba41b7beeed..bd0c35da94379 100644 --- a/question/tests/privacy_provider_test.php +++ b/question/tests/privacy_provider_test.php @@ -222,7 +222,7 @@ public function test_question_owned_is_handled() { $expectedcontext->id, $otherexpectedcontext->id, ]; - $this->assertEquals($expectedcontexts, $contextlist->get_contextids(), 'Contexts not equal', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expectedcontexts, $contextlist->get_contextids(), 'Contexts not equal'); // Run the export_user_Data as the test user. $this->setUser($user); @@ -460,10 +460,9 @@ public function test_get_users_in_context() { // User1 has created questions and user3 has edited them. $this->assertCount(2, $userlist); - $this->assertEquals( + $this->assertEqualsCanonicalizing( [$user1->id, $user3->id], - $userlist->get_userids(), - '', 0.0, 10, true); + $userlist->get_userids()); } /** diff --git a/question/type/ddwtos/tests/questiontype_test.php b/question/type/ddwtos/tests/questiontype_test.php index 2f650ca0b2549..b98324e160144 100644 --- a/question/type/ddwtos/tests/questiontype_test.php +++ b/question/type/ddwtos/tests/questiontype_test.php @@ -157,7 +157,7 @@ public function test_initialise_question_instance() { public function test_get_random_guess_score() { $q = $this->get_test_question_data(); - $this->assertEquals(0.5, $this->qtype->get_random_guess_score($q), '', 0.0000001); + $this->assertEqualsWithDelta(0.5, $this->qtype->get_random_guess_score($q), 0.0000001); } public function test_get_possible_responses() { diff --git a/question/type/gapselect/tests/questiontype_test.php b/question/type/gapselect/tests/questiontype_test.php index 6598983ead60e..6138e23d92d96 100644 --- a/question/type/gapselect/tests/questiontype_test.php +++ b/question/type/gapselect/tests/questiontype_test.php @@ -114,7 +114,7 @@ public function test_initialise_question_instance() { public function test_get_random_guess_score() { $q = $this->get_test_question_data(); - $this->assertEquals(0.5, $this->qtype->get_random_guess_score($q), '', 0.0000001); + $this->assertEqualsWithDelta(0.5, $this->qtype->get_random_guess_score($q), 0.0000001); } public function test_get_possible_responses() { diff --git a/question/type/match/tests/questiontype_test.php b/question/type/match/tests/questiontype_test.php index dd9ee1c806e14..ae7457a0ce343 100644 --- a/question/type/match/tests/questiontype_test.php +++ b/question/type/match/tests/questiontype_test.php @@ -134,7 +134,7 @@ public function test_make_question_instance() { public function test_get_random_guess_score() { $q = $this->get_test_question_data(); - $this->assertEquals(0.3333333, $this->qtype->get_random_guess_score($q), '', 0.0000001); + $this->assertEqualsWithDelta(0.3333333, $this->qtype->get_random_guess_score($q), 0.0000001); } public function test_get_possible_responses() { diff --git a/question/type/multianswer/tests/questiontype_test.php b/question/type/multianswer/tests/questiontype_test.php index defb2bda1da24..c1d46a5fe91cd 100644 --- a/question/type/multianswer/tests/questiontype_test.php +++ b/question/type/multianswer/tests/questiontype_test.php @@ -112,7 +112,7 @@ public function test_can_analyse_responses() { public function test_get_random_guess_score() { $q = test_question_maker::get_question_data('multianswer', 'twosubq'); - $this->assertEquals(0.1666667, $this->qtype->get_random_guess_score($q), '', 0.0000001); + $this->assertEqualsWithDelta(0.1666667, $this->qtype->get_random_guess_score($q), 0.0000001); } public function test_load_question() { diff --git a/question/type/multichoice/tests/question_multi_test.php b/question/type/multichoice/tests/question_multi_test.php index 1e5f56bc452e9..d0620243ccf57 100644 --- a/question/type/multichoice/tests/question_multi_test.php +++ b/question/type/multichoice/tests/question_multi_test.php @@ -171,7 +171,7 @@ public function test_prepare_simulated_post_data() { foreach ($correctanswers as $correctanswer) { $postdata = $mc->prepare_simulated_post_data($correctanswer); $simulatedreponse = $mc->get_student_response_values_for_simulation($postdata); - $this->assertEquals($correctanswer, $simulatedreponse, '', 0, 10, true); + $this->assertEqualsCanonicalizing($correctanswer, $simulatedreponse); } } diff --git a/question/type/multichoice/tests/question_single_test.php b/question/type/multichoice/tests/question_single_test.php index 6d4eff2f8ad9c..dcb08d640bf2e 100644 --- a/question/type/multichoice/tests/question_single_test.php +++ b/question/type/multichoice/tests/question_single_test.php @@ -139,7 +139,7 @@ public function test_grading_rounding_three_right() { $mc->start_attempt(new question_attempt_step(), 1); list($grade, $state) = $mc->grade_response($mc->prepare_simulated_post_data(array('1' => '1', '3' => '1', '5' => '1'))); - $this->assertEquals(1, $grade, '', 0.000001); + $this->assertEqualsWithDelta(1, $grade, 0.000001); $this->assertEquals(question_state::$gradedright, $state); } diff --git a/question/type/numerical/tests/answerprocessor_test.php b/question/type/numerical/tests/answerprocessor_test.php index f27bb2ff89054..8f1dbe595bd0c 100644 --- a/question/type/numerical/tests/answerprocessor_test.php +++ b/question/type/numerical/tests/answerprocessor_test.php @@ -89,13 +89,13 @@ protected function verify_value_and_unit($exectedval, $expectedunit, $expectedmu if (is_null($exectedval)) { $this->assertNull($val); } else { - $this->assertEquals($exectedval, $val, '', 0.0001); + $this->assertEqualsWithDelta($exectedval, $val, 0.0001); } $this->assertEquals($expectedunit, $unit); if (is_null($expectedmultiplier)) { $this->assertNull($multiplier); } else { - $this->assertEquals($expectedmultiplier, $multiplier, '', 0.0001); + $this->assertEqualsWithDelta($expectedmultiplier, $multiplier, 0.0001); } } diff --git a/repository/contentbank/tests/browser_test.php b/repository/contentbank/tests/browser_test.php index 6a3efd31d9683..fec563eff1e3f 100644 --- a/repository/contentbank/tests/browser_test.php +++ b/repository/contentbank/tests/browser_test.php @@ -89,7 +89,7 @@ public function test_get_content_system_context_user_has_capabilities() { ] ]; $expected = $this->generate_expected_content($contextfolders, $contentbankcontents); - $this->assertEquals($expected, $repositorycontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontentnodes); // Log in as a user. $this->setUser($user); @@ -101,7 +101,7 @@ public function test_get_content_system_context_user_has_capabilities() { // the content of the category's courses. $this->assertCount(3, $repositorycontentnodes); $expected = $this->generate_expected_content([], $contentbankcontents); - $this->assertEquals($expected, $repositorycontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontentnodes); // Enrol the user as an editing teacher in the course. $editingteacherrole = $DB->get_field('role', 'id', ['shortname' => 'editingteacher']); @@ -122,7 +122,7 @@ public function test_get_content_system_context_user_has_capabilities() { ] ]; $expected = $this->generate_expected_content($contextfolders, $contentbankcontents); - $this->assertEquals($expected, $repositorycontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontentnodes); } /** @@ -197,7 +197,7 @@ public function test_get_content_course_category_context_user_has_capabilities() ] ]; $expected = $this->generate_expected_content($contextfolders, $contentbankcontents); - $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontents); // Log in as an editing teacher enrolled in a child course. $this->setUser($editingteacher); @@ -215,7 +215,7 @@ public function test_get_content_course_category_context_user_has_capabilities() ] ]; $expected = $this->generate_expected_content($contextfolders, $contentbankcontents); - $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontents); } /** @@ -302,7 +302,7 @@ public function test_get_content_course_context_user_has_capabilities() { // course context. $this->assertCount(3, $repositorycontents); $expected = $this->generate_expected_content([], $contentbankcontents); - $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontents); // Log in as an editing teacher. $this->setUser($editingteacher); @@ -314,7 +314,7 @@ public function test_get_content_course_context_user_has_capabilities() { // course context. $this->assertCount(3, $repositorycontents); $expected = $this->generate_expected_content([], $contentbankcontents); - $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $repositorycontents); } /** diff --git a/repository/contentbank/tests/search_test.php b/repository/contentbank/tests/search_test.php index 84089f411a526..2ac4dc235a02c 100644 --- a/repository/contentbank/tests/search_test.php +++ b/repository/contentbank/tests/search_test.php @@ -65,7 +65,7 @@ public function test_get_search_contents(array $contentnames, string $search, ar return $searchcontentnode['shorttitle']; }, $searchcontentnodes); - $this->assertEquals($expected, $actual, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $actual); } /** @@ -172,7 +172,7 @@ public function test_get_search_contents_user_can_access_all_content() { \repository_contentbank\helper::create_contentbank_content_node($categorycontent), \repository_contentbank\helper::create_contentbank_content_node($coursecontent), ]; - $this->assertEquals($expected, $searchcontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $searchcontentnodes); } /** @@ -224,7 +224,7 @@ public function test_get_search_contents_user_can_access_certain_content() { \repository_contentbank\helper::create_contentbank_content_node($systemcontent), \repository_contentbank\helper::create_contentbank_content_node($course1content), ]; - $this->assertEquals($expected, $searchcontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $searchcontentnodes); // Log in as a teacher. $this->setUser($teacher); @@ -236,6 +236,6 @@ public function test_get_search_contents_user_can_access_certain_content() { $expected = [ \repository_contentbank\helper::create_contentbank_content_node($systemcontent), ]; - $this->assertEquals($expected, $searchcontentnodes, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expected, $searchcontentnodes); } }