mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-71036 phpunit: assertContains() now performs strict comparison
The methods assertContains() and assertNotContains() now perform strict (type and value) comparison, pretty much like assertSame() does. A couple of new assertContainsEquals() and assertNotContainsEquals() methods have been created to provide old (non-strict) behavior, pretty much like assertEquals() do. Apart from replacing the calls needing a relaxed comparison to those new methods, there are also a couple of alternative, about how to fix this, depending of every case: - If the test is making any array_values() conversion, then it's better to remove that conversion and use assertArrayHasKey(), that is not strict. - Sometimes if may be also possible to, simply, cast the expectation to the exact type coming in the array. I've not applied this technique to any of the cases in core. Link: https://github.com/sebastianbergmann/phpunit/issues/3426
This commit is contained in:
parent
8940f67486
commit
3dd26fe334
27 changed files with 139 additions and 143 deletions
|
@ -4395,7 +4395,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
|||
$leastarray = array($comp4->get('id'), $comp6->get('id'));
|
||||
foreach ($result as $one) {
|
||||
$this->assertInstanceOf('\core_competency\competency', $one);
|
||||
$this->assertContains($one->get('id'), $leastarray);
|
||||
$this->assertContainsEquals($one->get('id'), $leastarray);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue