MDL-63826 tests: Don't rely on random array keys for testing
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 31 Oct 2018 23:24:54 +0000 (00:24 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 31 Oct 2018 23:28:35 +0000 (00:28 +0100)
mod/assign/submission/comments/tests/privacy_test.php

index c02e795..e30e7ee 100644 (file)
@@ -174,9 +174,11 @@ class assignsubmission_comments_privacy_testcase extends \mod_assign\tests\mod_a
         \assignsubmission_comments\privacy\provider::get_userids_from_context($userlist);
         $userids = $userlist->get_userids();
         $this->assertCount(3, $userids);
-        // Two is the key for user 3.
-        $this->assertEquals(2, array_search($user3->id, $userids));
-        $this->assertFalse(array_search($user4->id, $userids));
+        // User 1,2 and 3 are the expected ones in the array. User 4 isn't.
+        $this->assertContains($user1->id, $userids);
+        $this->assertContains($user2->id, $userids);
+        $this->assertContains($user3->id, $userids);
+        $this->assertNotContains($user4->id, $userids);
     }
 
     /**