MDL-67673 phpunit: Remove deprecated assertArraySubset()

While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

assertArraySubset() is deprecated and will be removed in PHPUnit 9.
This commit is contained in:
Eloy Lafuente (stronk7) 2020-08-02 13:43:32 +02:00
parent f94195c320
commit 598d578af7
2 changed files with 11 additions and 4 deletions

View File

@ -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);
}
/**

View File

@ -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]);
}
}
/**