MDL-67673 phpunit: Remove deprecated assertEquals() params
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 1 Sep 2020 23:14:14 +0000 (01:14 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 21 Oct 2020 10:46:05 +0000 (12:46 +0200)
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.

70 files changed:
admin/roles/tests/privacy_test.php
admin/tool/cohortroles/tests/privacy_test.php
admin/tool/dataprivacy/tests/manager_observer_test.php
admin/tool/policy/tests/privacy_provider_test.php
admin/tool/uploadcourse/tests/course_test.php
auth/oauth2/tests/auth_test.php
backup/tests/privacy_provider_test.php
blocks/comments/tests/privacy_provider_test.php
blog/tests/privacy_test.php
cache/tests/fixtures/stores.php
calendar/tests/lib_test.php
calendar/tests/raw_event_retrieval_strategy_test.php
course/tests/externallib_test.php
customfield/tests/privacy_test.php
enrol/flatfile/tests/privacy_provider_test.php
enrol/lti/tests/privacy_provider_test.php
enrol/meta/tests/privacy_test.php
enrol/paypal/tests/privacy_provider_test.php
enrol/tests/enrollib_test.php
enrol/tests/externallib_test.php
favourites/tests/privacy_test.php
grade/tests/edittreelib_test.php
grade/tests/privacy_test.php
group/tests/privacy_provider_test.php
iplookup/tests/geoplugin_test.php
lib/ddl/tests/ddl_test.php
lib/dml/tests/dml_test.php
lib/grade/tests/grade_item_test.php
lib/phpunit/tests/basic_test.php
lib/tests/accesslib_test.php
lib/tests/blocklib_test.php
lib/tests/filterlib_test.php
lib/tests/grouplib_test.php
lib/tests/mathslib_test.php
lib/tests/moodlelib_test.php
lib/tests/session_manager_test.php
lib/tests/time_splittings_test.php
message/tests/privacy_provider_test.php
mod/data/tests/lib_test.php
mod/glossary/tests/external_test.php
mod/quiz/report/statistics/tests/statistics_test.php
mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php
mod/quiz/tests/local_structure_slot_random_test.php
mod/quiz/tests/locallib_test.php
mod/quiz/tests/privacy_provider_test.php
mod/quiz/tests/tags_test.php
mod/wiki/tests/lib_test.php
mod/wiki/tests/privacy_test.php
mod/workshop/tests/privacy_provider_test.php
question/behaviour/adaptive/tests/walkthrough_test.php
question/behaviour/adaptivenopenalty/tests/walkthrough_test.php
question/behaviour/deferredcbm/tests/question_cbm_test.php
question/behaviour/deferredcbm/tests/walkthrough_test.php
question/behaviour/deferredfeedback/tests/walkthrough_test.php
question/behaviour/immediatecbm/tests/walkthrough_test.php
question/behaviour/immediatefeedback/tests/walkthrough_test.php
question/behaviour/interactive/tests/walkthrough_test.php
question/engine/tests/helpers.php
question/engine/tests/questionattemptstep_test.php
question/engine/tests/unitofwork_test.php
question/tests/privacy_provider_test.php
question/type/ddwtos/tests/questiontype_test.php
question/type/gapselect/tests/questiontype_test.php
question/type/match/tests/questiontype_test.php
question/type/multianswer/tests/questiontype_test.php
question/type/multichoice/tests/question_multi_test.php
question/type/multichoice/tests/question_single_test.php
question/type/numerical/tests/answerprocessor_test.php
repository/contentbank/tests/browser_test.php
repository/contentbank/tests/search_test.php

index 258b5a7..82203c1 100644 (file)
@@ -536,7 +536,7 @@ class core_role_privacy_testcase extends provider_testcase {
             $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 @@ class core_role_privacy_testcase extends provider_testcase {
             $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 @@ class core_role_privacy_testcase extends provider_testcase {
             $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 @@ class core_role_privacy_testcase extends provider_testcase {
             $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 @@ class core_role_privacy_testcase extends provider_testcase {
             $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 @@ class core_role_privacy_testcase extends provider_testcase {
             $user1->id,
             $admin->id
         ];
-        $this->assertEquals($expected, $userlist8->get_userids(), '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $userlist8->get_userids());
     }
 
     /**
@@ -744,4 +744,4 @@ class core_role_privacy_testcase extends provider_testcase {
         }
         return $rolesnames;
     }
-}
\ No newline at end of file
+}
index 72446a2..e5c4b9c 100644 (file)
@@ -87,7 +87,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
             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);
     }
 
     /**
index 1c47153..a68bd88 100644 (file)
@@ -63,7 +63,7 @@ class tool_dataprivacy_manager_observer_testcase extends data_privacy_testcase {
             return $message->useridto;
         }, $messages);
 
-        $this->assertEquals(array_keys($dpos), $messageusers, '', 0.0, 0, true);
+        $this->assertEqualsCanonicalizing(array_keys($dpos), $messageusers);
     }
 
     /**
index 6fa4a0d..e0d5ea5 100644 (file)
@@ -274,13 +274,9 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
         // 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 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
         // 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);
index 400e7ea..cd3dd41 100644 (file)
@@ -1228,7 +1228,7 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
 
         // 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);
     }
index 71bbce2..4582d70 100644 (file)
@@ -42,10 +42,7 @@ class auth_oauth2_auth_testcase extends advanced_testcase {
         $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']);
index 4bec91e..aec7eb6 100644 (file)
@@ -482,7 +482,7 @@ class core_backup_privacy_provider_testcase extends \core_privacy\tests\provider
         $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);
index 1962cc1..e239ba7 100644 (file)
@@ -209,7 +209,7 @@ class block_comments_privacy_provider_testcase extends \core_privacy\tests\provi
         $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);
     }
 
     /**
index 67de624..5eab70b 100644 (file)
@@ -690,7 +690,7 @@ class core_blog_privacy_testcase extends provider_testcase {
             $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);
index 36329c4..f415272 100644 (file)
@@ -116,10 +116,10 @@ abstract class cachestore_tests extends advanced_testcase {
         // 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'));
index d390125..6fb459d 100644 (file)
@@ -827,10 +827,9 @@ class core_calendar_lib_testcase extends advanced_testcase {
         $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 @@ class core_calendar_lib_testcase extends advanced_testcase {
         $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 @@ class core_calendar_lib_testcase extends advanced_testcase {
         $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);
     }
index b195eea..5bedcb1 100644 (file)
@@ -402,10 +402,9 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
         // 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 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc
         // 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'));
     }
 
     /**
index f6bc7b6..766a0c1 100644 (file)
@@ -240,7 +240,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
             $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(
index 4a63085..6f9a480 100644 (file)
@@ -116,9 +116,9 @@ class core_customfield_privacy_testcase extends provider_testcase {
         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());
     }
 
     /**
index 0b99cfc..7c9f22d 100644 (file)
@@ -218,11 +218,9 @@ class enrol_flatfile_privacy_testcase extends provider_testcase {
         // 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 @@ class enrol_flatfile_privacy_testcase extends provider_testcase {
         // 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]);
index dfcaf07..16ebcb1 100644 (file)
@@ -92,7 +92,7 @@ class enrol_lti_privacy_provider_testcase extends \core_privacy\tests\provider_t
         $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 @@ class enrol_lti_privacy_provider_testcase extends \core_privacy\tests\provider_t
         $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());
     }
 
     /**
index d9951b2..60ed24c 100644 (file)
@@ -294,9 +294,8 @@ class enrol_meta_privacy_testcase extends \core_privacy\tests\provider_testcase
         $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());
     }
 }
index 25b6304..391a7d9 100644 (file)
@@ -302,7 +302,7 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
         $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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
 
         $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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
 
         $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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
                     $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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
                     $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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
                 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 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide
                 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,
index 9604b19..0965efa 100644 (file)
@@ -159,7 +159,7 @@ class core_enrollib_testcase extends advanced_testcase {
         $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);
index 09a01ad..a12df0b 100644 (file)
@@ -351,7 +351,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
                 $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 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
                 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);
index d7fe912..d7890ee 100644 (file)
@@ -164,7 +164,7 @@ class privacy_test extends provider_testcase {
             $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');
index b24608d..93d7983 100644 (file)
@@ -79,7 +79,7 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
 
         $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();
index d721dee..e1b3959 100644 (file)
@@ -390,12 +390,12 @@ class core_grades_privacy_testcase extends provider_testcase {
         $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);
index 3e8ff58..0f0e20c 100644 (file)
@@ -96,10 +96,9 @@ class core_group_privacy_provider_testcase extends provider_testcase {
         $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 @@ class core_group_privacy_provider_testcase extends provider_testcase {
         $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 @@ class core_group_privacy_provider_testcase extends provider_testcase {
         $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 @@ class core_group_privacy_provider_testcase extends provider_testcase {
         $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 @@ class core_group_privacy_provider_testcase extends provider_testcase {
 
         // 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());
     }
 }
index 3ebe8b4..491308e 100644 (file)
@@ -51,8 +51,8 @@ class core_iplookup_geoplugin_testcase extends advanced_testcase {
 
         $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]);
index 35526ac..dd09cc6 100644 (file)
@@ -574,7 +574,7 @@ class core_ddl_testcase extends database_driver_testcase {
             $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 @@ class core_ddl_testcase extends database_driver_testcase {
             $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 @@ class core_ddl_testcase extends database_driver_testcase {
         $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);
     }
index c2fc921..bff9b97 100644 (file)
@@ -1410,7 +1410,7 @@ EOD;
             $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 @@ EOD;
         $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 @@ EOD;
         $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";
index 5c0b46b..28b7f9c 100644 (file)
@@ -427,14 +427,14 @@ class core_grade_item_testcase extends grade_base_testcase {
 
         // 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() {
index 9ef7e1d..df989ee 100644 (file)
@@ -72,7 +72,7 @@ class core_phpunit_basic_testcase extends basic_testcase {
         $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();
index 42d147a..a0f549c 100644 (file)
@@ -676,13 +676,13 @@ class core_accesslib_testcase extends advanced_testcase {
         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 @@ class core_accesslib_testcase extends advanced_testcase {
         $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 @@ class core_accesslib_testcase extends advanced_testcase {
         $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);
index c68ca54..f15ce7b 100644 (file)
@@ -98,7 +98,7 @@ class core_blocklib_testcase extends advanced_testcase {
         // 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 @@ class core_blocklib_testcase extends advanced_testcase {
         $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 @@ class core_blocklib_testcase extends advanced_testcase {
         // 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 @@ class core_blocklib_testcase extends advanced_testcase {
         $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 @@ class core_blocklib_testcase extends advanced_testcase {
     }
 
     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 = '') {
index a211964..6271902 100644 (file)
@@ -339,7 +339,7 @@ class core_filterlib_testcase extends advanced_testcase {
     }
 
     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() {
index 7f62f08..b057d50 100644 (file)
@@ -1109,10 +1109,9 @@ class core_grouplib_testcase extends advanced_testcase {
         // 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 @@ class core_grouplib_testcase extends advanced_testcase {
         $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 @@ class core_grouplib_testcase extends advanced_testcase {
         // 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 @@ class core_grouplib_testcase extends advanced_testcase {
         $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));
     }
 }
index 9992175..b1e71f7 100644 (file)
@@ -295,19 +295,19 @@ class core_mathslib_testcase extends basic_testcase {
 
     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() {
index 68dd0e0..ff52d2c 100644 (file)
@@ -3957,7 +3957,7 @@ class core_moodlelib_testcase extends advanced_testcase {
         $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();
index a71d1ac..968dafb 100644 (file)
@@ -64,7 +64,7 @@ class core_session_manager_testcase extends advanced_testcase {
         $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 @@ class core_session_manager_testcase extends advanced_testcase {
         $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);
     }
index 646bbf4..224fbeb 100644 (file)
@@ -247,13 +247,13 @@ class core_analytics_time_splittings_testcase extends advanced_testcase {
         $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 @@ class core_analytics_time_splittings_testcase extends advanced_testcase {
         $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 @@ class core_analytics_time_splittings_testcase extends advanced_testcase {
         $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']);
index 5c0ad08..07e2037 100644 (file)
@@ -1631,7 +1631,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
         // 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');
index c4ae832..88d7166 100644 (file)
@@ -1311,7 +1311,7 @@ class mod_data_lib_testcase extends advanced_testcase {
         // 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() {
index d25ce90..18bbcc8 100644 (file)
@@ -914,7 +914,7 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
         // 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 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
                 $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 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
         // 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 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
         // 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));
index 1ab74e8..d4bfeaf 100644 (file)
@@ -144,7 +144,7 @@ class quiz_statistics_question_stats_testcase extends basic_testcase {
         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);
             }
index 53cb217..da80848 100644 (file)
@@ -151,7 +151,7 @@ class quiz_report_statistics_from_steps_testcase extends mod_quiz_attempt_walkth
                     $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 @@ class quiz_report_statistics_from_steps_testcase extends mod_quiz_attempt_walkth
             $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 @@ class quiz_report_statistics_from_steps_testcase extends mod_quiz_attempt_walkth
                     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 @@ class quiz_report_statistics_from_steps_testcase extends mod_quiz_attempt_walkth
         );
 
         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);
         }
     }
 
index a9c1cd5..6187262 100644 (file)
@@ -400,14 +400,13 @@ class mod_quiz_local_structure_slot_random_test extends advanced_testcase {
         $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
+}
index 453d9d1..7b9ee84 100644 (file)
@@ -519,15 +519,14 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
         $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 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
         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 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
         $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 @@ class mod_quiz_locallib_testcase extends advanced_testcase {
         $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);
     }
 
     /**
index 40c533f..74ccd47 100644 (file)
@@ -489,10 +489,9 @@ class mod_quiz_privacy_provider_testcase extends \core_privacy\tests\provider_te
         // 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());
     }
 
     /**
index 094abb2..7781f00 100644 (file)
@@ -84,14 +84,13 @@ class mod_quiz_tags_testcase extends advanced_testcase {
         $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);
index 172ebf7..a4099ad 100644 (file)
@@ -468,7 +468,7 @@ class mod_wiki_lib_testcase extends advanced_testcase {
         $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 @@ class mod_wiki_lib_testcase extends advanced_testcase {
         // 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 @@ class mod_wiki_lib_testcase extends advanced_testcase {
         // 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 @@ class mod_wiki_lib_testcase extends advanced_testcase {
         // 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 @@ class mod_wiki_lib_testcase extends advanced_testcase {
         // 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() {
index e28f6db..b4c98ba 100644 (file)
@@ -247,26 +247,26 @@ class mod_wiki_privacy_testcase extends provider_testcase {
 
         // 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 @@ class mod_wiki_privacy_testcase extends provider_testcase {
 
         // 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]]);
index 7a09384..fccbbb4 100644 (file)
@@ -189,19 +189,19 @@ class mod_workshop_privacy_provider_testcase extends advanced_testcase {
         // 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 @@ class mod_workshop_privacy_provider_testcase extends advanced_testcase {
             $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 @@ class mod_workshop_privacy_provider_testcase extends advanced_testcase {
             $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 @@ class mod_workshop_privacy_provider_testcase extends advanced_testcase {
             $this->teacher4->id, // Teacher4 has data in workshop21 (gradinggradeoverby).
         ];
         $actual21 = $userlist21->get_userids();
-        $this->assertEquals($expected21, $actual21, '', 0, 10, true);
+        $this->assertEqualsCanonicalizing($expected21, $actual21);
     }
 
     /**
index 9158ac3..282d49a 100644 (file)
@@ -181,7 +181,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
                 $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() {
index 49d5a66..62cb7da 100644 (file)
@@ -163,7 +163,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou
                 $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() {
index 16d0d39..20fc6fc 100644 (file)
@@ -40,17 +40,17 @@ require_once(__DIR__ . '/../../../engine/lib.php');
 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);
     }
 }
index b139c96..c961e8b 100644 (file)
@@ -113,7 +113,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
         $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() {
index c170aa4..18bfbe2 100644 (file)
@@ -110,7 +110,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug
         $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() {
index 71d8b71..f0e1890 100644 (file)
@@ -130,7 +130,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te
                 $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() {
index b95c204..93953b4 100644 (file)
@@ -137,7 +137,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou
                 $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() {
index 2f182c5..ec21240 100644 (file)
@@ -176,7 +176,7 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes
                 $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() {
index 733efd7..b9bcfa4 100644 (file)
@@ -898,8 +898,8 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
                 // 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.');
         }
     }
 
index 9c55790..b7a73ab 100644 (file)
@@ -112,7 +112,7 @@ class question_attempt_step_test extends advanced_testcase {
     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());
index af86f11..e7ee557 100644 (file)
@@ -363,7 +363,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base {
 
     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()));
 
index 50ba41b..bd0c35d 100644 (file)
@@ -222,7 +222,7 @@ class core_question_privacy_provider_testcase extends \core_privacy\tests\provid
                 $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 @@ class core_question_privacy_provider_testcase extends \core_privacy\tests\provid
 
         // 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());
     }
 
     /**
index 2f650ca..b98324e 100644 (file)
@@ -157,7 +157,7 @@ class qtype_ddwtos_test extends question_testcase {
 
     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() {
index 6598983..6138e23 100644 (file)
@@ -114,7 +114,7 @@ class qtype_gapselect_test extends question_testcase {
 
     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() {
index dd9ee1c..ae7457a 100644 (file)
@@ -134,7 +134,7 @@ class qtype_match_test extends advanced_testcase {
 
     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() {
index defb2bd..c1d46a5 100644 (file)
@@ -112,7 +112,7 @@ class qtype_multianswer_test extends advanced_testcase {
 
     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() {
index 1e5f56b..d062024 100644 (file)
@@ -171,7 +171,7 @@ class qtype_multichoice_multi_question_test extends advanced_testcase {
         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);
         }
     }
 
index 6d4eff2..dcb08d6 100644 (file)
@@ -139,7 +139,7 @@ class qtype_multichoice_single_question_test extends advanced_testcase {
         $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);
     }
 
index f27bb2f..8f1dbe5 100644 (file)
@@ -89,13 +89,13 @@ class qtype_numerical_answer_processor_test extends advanced_testcase {
         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);
         }
     }
 
index 6a3efd3..fec563e 100644 (file)
@@ -89,7 +89,7 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
             ]
         ];
         $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 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
         // 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 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
             ]
         ];
         $expected = $this->generate_expected_content($contextfolders, $contentbankcontents);
-        $this->assertEquals($expected, $repositorycontentnodes, '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $repositorycontentnodes);
     }
 
     /**
@@ -197,7 +197,7 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
             ]
         ];
         $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 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
             ]
         ];
         $expected = $this->generate_expected_content($contextfolders, $contentbankcontents);
-        $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $repositorycontents);
     }
 
     /**
@@ -302,7 +302,7 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
         // 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 @@ class repository_contentbank_browser_testcase extends advanced_testcase {
         // course context.
         $this->assertCount(3, $repositorycontents);
         $expected = $this->generate_expected_content([], $contentbankcontents);
-        $this->assertEquals($expected, $repositorycontents, '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $repositorycontents);
     }
 
     /**
index 84089f4..2ac4dc2 100644 (file)
@@ -65,7 +65,7 @@ class repository_contentbank_search_testcase extends advanced_testcase {
             return $searchcontentnode['shorttitle'];
         }, $searchcontentnodes);
 
-        $this->assertEquals($expected, $actual, '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $actual);
     }
 
     /**
@@ -172,7 +172,7 @@ class repository_contentbank_search_testcase extends advanced_testcase {
             \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 @@ class repository_contentbank_search_testcase extends advanced_testcase {
             \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 @@ class repository_contentbank_search_testcase extends advanced_testcase {
         $expected = [
             \repository_contentbank\helper::create_contentbank_content_node($systemcontent),
         ];
-        $this->assertEquals($expected, $searchcontentnodes, '', 0.0, 10, true);
+        $this->assertEqualsCanonicalizing($expected, $searchcontentnodes);
     }
 }