Open
Description
Q | A |
---|---|
PHPUnit version | 11.3.5 |
PHP version | 8.3.8 |
Installation Method | Composer |
Summary
The diff output when assertEqualsCanonicalizing() fails is affected by the order of the arrays.
Current behavior
Consider this assertion:
$this->assertEqualsCanonicalizing(
[
"alpha",
"beta",
],
[
"alpha",
"beta",
"gamma",
],
);
the output is:
--- Expected
+++ Actual
@@ @@
Array (
0 => 'alpha'
1 => 'beta'
+ 2 => 'gamma'
)
but with this assertion:
$this->assertEqualsCanonicalizing(
[
"alpha",
"gamma",
],
[
"alpha",
"beta",
"gamma",
],
);
The output is:
--- Expected
+++ Actual
@@ @@
Array (
0 => 'alpha'
- 1 => 'gamma'
+ 1 => 'beta'
+ 2 => 'gamma'
)
In both cases, there is one item extra item the actual value compared to the expected value, but in one case the diff shows that very clearly, and in the other case, the diff has extra noise.
How to reproduce
Expected behavior
Only 'beta' is surplus, so the output should be:
--- Expected
+++ Actual
@@ @@
Array (
+ 1 => 'beta'
)
Activity