phpunit
phpunit copied to clipboard
TestCase::assertEqualsCanonicalizing() not converts and sorts data recursively
| Q | A |
|---|---|
| PHPUnit version | >7.5.* |
| PHP version | >7.0.* |
| Installation Method | Composer |
Summary
Assertion method TestCase::assertEqualsCanonicalizing():
- not converts/sorts data recursively
- undocumented and invalid comparing object's classes
- use algorithm same to
assertEquals()insteadassertEqualsWithDelta()to compare float properties
Current behavior
undocumented and not usable to tests
How to reproduce
$this->assertEqualsCanonicalizing([(object) ['a' => 1, 'b' => 1]], [(object) ['b' => 1, 'a' => 1]])
class Dummy
{
}
$expected = new Dummy();
$expected->a = 1;
$expected->b = 0.333;
$actual = new Dummy();
$actual->b = 0.33333;
$actual->a = 1;
$this->assertEqualsCanonicalizing($expected, $actual);
class Parent
{
public $a = 'Foo';
}
class Child extend Parent
{
}
$this->assertEqualsCanonicalizing(new Parent(), new Child());
Epic fail...
Expected behavior
inverse of current behavior
@WinterSilence is it still an issue for you? I cannot reproduce it from the examples here in PHPUnit 10 (lowest supported, currently).