phpunitHow to use PHPUnit assertequalscanonicalizing?
PHPUnit's assertEqualsCanonicalizing
is a method used to compare two values for equality, while ignoring differences in their order. It is useful for comparing arrays or objects that may have different orderings.
Example
$expected = [1, 2, 3];
$actual = [3, 2, 1];
$this->assertEqualsCanonicalizing($expected, $actual);
Output example
OK
Code explanation
assertEqualsCanonicalizing
: The method used to compare two values for equality, while ignoring differences in their order.$expected
: The expected value to compare against.$actual
: The actual value to compare.
Helpful links
More of Phpunit
- How to skip a PHPUnit test?
- How to run tests in parallel with PHPUnit?
- How to use hooks in PHPUnit?
- What are PHPUnit required extensions
- How to use the PHPUnit Framework TestCase?
- How to run PHPUnit in quiet mode?
- How to show warnings in PHPUnit?
- How to load fixtures with PHPUnit?
- How to use a listener with PHPUnit?
- How to stop PHPUnit on failure?
See more codes...