Skip to content

Commit

Permalink
Merge pull request #36 from jrfnl/feature/add-support-for-phpunit-phar
Browse files Browse the repository at this point in the history
Add support for use with PHPUnit Phar
  • Loading branch information
rdohms committed Apr 7, 2021
2 parents 5e5d1b7 + c9086cf commit 2c671bf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Constraint/ArraySubset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
use ArrayObject;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\SebastianBergmann\Comparator\ComparisonFailure as Phar_ComparisonFailure;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Traversable;

use function array_replace_recursive;
use function class_exists;
use function is_array;
use function iterator_to_array;
use function var_export;
Expand Down Expand Up @@ -81,7 +83,14 @@ public function evaluate($other, string $description = '', bool $returnResult =
return null;
}

$f = new ComparisonFailure(
// Support use of this library when running PHPUnit as a Phar.
if (class_exists(Phar_ComparisonFailure::class) === true) {
$class = Phar_ComparisonFailure::class;
} else {
$class = ComparisonFailure::class;
}

$f = new $class(
$patched,
$other,
var_export($patched, true),
Expand Down

0 comments on commit 2c671bf

Please sign in to comment.