phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

New assetion `assertSameObjects()` to compare objects

Open WinterSilence opened this issue 3 years ago • 0 comments

Assertion to compare objects of diff classes. Syntax: function assertSameObjects(object $expected, object $actual, [bool $strict = false, string $message = '']) Behavior:

  1. Converts given objects to arrays of public property values
  2. Sort array by properties/keys
  3. Comparing property values: 3.1. float values compares same as assertEqualsWithDelta() 3.2. if $strict is true, then compare values strictly(i.e. use ===), else, recursive converts&sorts object values same as 1. and 2. and compare they using ==

WinterSilence avatar Feb 26 '22 18:02 WinterSilence