Skip to content

Commit d457893

Browse files
Closes #5810
1 parent 4fa9337 commit d457893

File tree

8 files changed

+77
-5
lines changed

8 files changed

+77
-5
lines changed

ChangeLog-13.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes of the PHPUnit 13.2 release series are documented in this fi
99
* [#3387](https://github.com/sebastianbergmann/phpunit/issues/3387): Specify a list of tests to run
1010
* [#4201](https://github.com/sebastianbergmann/phpunit/issues/4201): Handle interrupts and display current test results
1111
* [#5757](https://github.com/sebastianbergmann/phpunit/issues/5757): Add assertions for ignoring whitespace differences in strings
12+
* [#5810](https://github.com/sebastianbergmann/phpunit/issues/5810): Do not dump arrays and objects in failure messages of `IsTrue`, `IsFalse`, `IsNull`, `IsFinite`, `IsInfinite`, and `IsNan` constraints
1213
* [#6559](https://github.com/sebastianbergmann/phpunit/issues/6559): Improved API for exception message expectations
1314
* [#6566](https://github.com/sebastianbergmann/phpunit/pull/6566): Allow `--stop-on-defect`, `--stop-on-error`, etc. to accept an optional threshold
1415
* [#6567](https://github.com/sebastianbergmann/phpunit/issues/6567): Make diff context lines configurable

src/Framework/Constraint/Boolean/IsFalse.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
13+
use function is_object;
14+
use PHPUnit\Util\Exporter;
15+
1216
/**
1317
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1418
*/
@@ -30,4 +34,13 @@ protected function matches(mixed $other): bool
3034
{
3135
return $other === false;
3236
}
37+
38+
protected function failureDescription(mixed $other): string
39+
{
40+
if (is_array($other) || is_object($other)) {
41+
return $this->valueToTypeStringFragment($other) . $this->toString();
42+
}
43+
44+
return Exporter::export($other) . ' ' . $this->toString();
45+
}
3346
}

src/Framework/Constraint/Boolean/IsTrue.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
13+
use function is_object;
14+
use PHPUnit\Util\Exporter;
15+
1216
/**
1317
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1418
*/
@@ -30,4 +34,13 @@ protected function matches(mixed $other): bool
3034
{
3135
return $other === true;
3236
}
37+
38+
protected function failureDescription(mixed $other): string
39+
{
40+
if (is_array($other) || is_object($other)) {
41+
return $this->valueToTypeStringFragment($other) . $this->toString();
42+
}
43+
44+
return Exporter::export($other) . ' ' . $this->toString();
45+
}
3346
}

src/Framework/Constraint/Math/IsFinite.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
1213
use function is_finite;
14+
use function is_object;
15+
use PHPUnit\Util\Exporter;
1316

1417
/**
1518
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -32,4 +35,13 @@ protected function matches(mixed $other): bool
3235
{
3336
return is_finite($other);
3437
}
38+
39+
protected function failureDescription(mixed $other): string
40+
{
41+
if (is_array($other) || is_object($other)) {
42+
return $this->valueToTypeStringFragment($other) . $this->toString();
43+
}
44+
45+
return Exporter::export($other) . ' ' . $this->toString();
46+
}
3547
}

src/Framework/Constraint/Math/IsInfinite.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
1213
use function is_infinite;
14+
use function is_object;
15+
use PHPUnit\Util\Exporter;
1316

1417
/**
1518
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -32,4 +35,13 @@ protected function matches(mixed $other): bool
3235
{
3336
return is_infinite($other);
3437
}
38+
39+
protected function failureDescription(mixed $other): string
40+
{
41+
if (is_array($other) || is_object($other)) {
42+
return $this->valueToTypeStringFragment($other) . $this->toString();
43+
}
44+
45+
return Exporter::export($other) . ' ' . $this->toString();
46+
}
3547
}

src/Framework/Constraint/Math/IsNan.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
1213
use function is_nan;
14+
use function is_object;
15+
use PHPUnit\Util\Exporter;
1316

1417
/**
1518
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -32,4 +35,13 @@ protected function matches(mixed $other): bool
3235
{
3336
return is_nan($other);
3437
}
38+
39+
protected function failureDescription(mixed $other): string
40+
{
41+
if (is_array($other) || is_object($other)) {
42+
return $this->valueToTypeStringFragment($other) . $this->toString();
43+
}
44+
45+
return Exporter::export($other) . ' ' . $this->toString();
46+
}
3547
}

src/Framework/Constraint/Type/IsNull.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
namespace PHPUnit\Framework\Constraint;
1111

12+
use function is_array;
13+
use function is_object;
14+
use PHPUnit\Util\Exporter;
15+
1216
/**
1317
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1418
*/
@@ -30,4 +34,13 @@ protected function matches(mixed $other): bool
3034
{
3135
return $other === null;
3236
}
37+
38+
protected function failureDescription(mixed $other): string
39+
{
40+
if (is_array($other) || is_object($other)) {
41+
return $this->valueToTypeStringFragment($other) . $this->toString();
42+
}
43+
44+
return Exporter::export($other) . ' ' . $this->toString();
45+
}
3346
}

tests/end-to-end/regression/5567.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ Time: %s, Memory: %s MB
2020
There was 1 failure:
2121

2222
1) PHPUnit\TestFixture\Issue5567\Issue5567Test::testAnythingThatFailsWithRecursiveArray
23-
Failed asserting that Array &0 [
24-
'self' => Array &1 [
25-
'self' => Array &1,
26-
],
27-
] is false.
23+
Failed asserting that an array is false.
2824

2925
%sIssue5567Test.php:%d
3026

0 commit comments

Comments
 (0)