Skip to content

Commit 2c671bf

Browse files
authored
Merge pull request #36 from jrfnl/feature/add-support-for-phpunit-phar
Add support for use with PHPUnit Phar
2 parents 5e5d1b7 + c9086cf commit 2c671bf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Constraint/ArraySubset.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use ArrayObject;
88
use PHPUnit\Framework\Constraint\Constraint;
99
use PHPUnit\Framework\ExpectationFailedException;
10+
use PHPUnit\SebastianBergmann\Comparator\ComparisonFailure as Phar_ComparisonFailure;
1011
use SebastianBergmann\Comparator\ComparisonFailure;
1112
use SebastianBergmann\RecursionContext\InvalidArgumentException;
1213
use Traversable;
1314

1415
use function array_replace_recursive;
16+
use function class_exists;
1517
use function is_array;
1618
use function iterator_to_array;
1719
use function var_export;
@@ -81,7 +83,14 @@ public function evaluate($other, string $description = '', bool $returnResult =
8183
return null;
8284
}
8385

84-
$f = new ComparisonFailure(
86+
// Support use of this library when running PHPUnit as a Phar.
87+
if (class_exists(Phar_ComparisonFailure::class) === true) {
88+
$class = Phar_ComparisonFailure::class;
89+
} else {
90+
$class = ComparisonFailure::class;
91+
}
92+
93+
$f = new $class(
8594
$patched,
8695
$other,
8796
var_export($patched, true),

0 commit comments

Comments
 (0)