diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 568db66b18b..42d147a5dd8 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -3567,9 +3567,12 @@ class core_accesslib_testcase extends advanced_testcase { protected function assert_capability_list_contains($expected, $actual) { $actualnames = []; foreach ($actual as $cap) { - $actualnames[$cap->name] = $cap->name; + $actualnames[] = $cap->name; + } + // Verify each expected element exists. + foreach ($expected as $key => $value) { + $this->assertContains($value, $actualnames); } - $this->assertArraySubset(array_combine($expected, $expected), $actualnames); } /** diff --git a/mod/forum/tests/grades_gradeitems_test.php b/mod/forum/tests/grades_gradeitems_test.php index 40df1658709..b68c84cf95f 100644 --- a/mod/forum/tests/grades_gradeitems_test.php +++ b/mod/forum/tests/grades_gradeitems_test.php @@ -48,8 +48,12 @@ class gradeitems_test extends advanced_testcase { $mappings = component_gradeitems::get_itemname_mapping_for_component('mod_forum'); $this->assertIsArray($mappings); $this->assertCount(2, $mappings); - $this->assertArraySubset([0 => 'rating'], $mappings); - $this->assertArraySubset([1 => 'forum'], $mappings); + $expected = [0 => 'rating', 1 => 'forum']; + // Verify each expected element exists and its value matches. + foreach ($expected as $key => $value) { + $this->assertArrayHasKey($key, $mappings); + $this->assertSame($value, $mappings[$key]); + } } /**