phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

TestCase::assertEqualsCanonicalizing() not converts and sorts data recursively

Open WinterSilence opened this issue 3 years ago • 1 comments

Q A
PHPUnit version >7.5.*
PHP version >7.0.*
Installation Method Composer

Summary

Assertion method TestCase::assertEqualsCanonicalizing():

  1. not converts/sorts data recursively
  2. undocumented and invalid comparing object's classes
  3. use algorithm same to assertEquals() instead assertEqualsWithDelta() 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 avatar Feb 26 '22 16:02 WinterSilence

@WinterSilence is it still an issue for you? I cannot reproduce it from the examples here in PHPUnit 10 (lowest supported, currently).

kubawerlos avatar Sep 07 '24 19:09 kubawerlos