Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add compatibility with PHPUnit 11 #81

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "This package provides ArraySubset and related asserts once deprecated in PHPUnit 8",
"type": "library",
"require": {
"phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
"phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"php": "^5.4 || ^7.0 || ^8.0"
},
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion src/Constraint/ArraySubset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\SebastianBergmann\Comparator\ComparisonFailure as Phar_ComparisonFailure;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Exporter\Exporter;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this will break when people use the PHPUnit PHAR file to run tests

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be interesting to find a way to run a test suite with phar in these cases right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added that (running the test against PHARs in CI) for the PHPUnit Polyfills too. You should be able to use that change as an example for how to set that up: Yoast/PHPUnit-Polyfills#160

Also note that the latest PHPUnit releases contain a change in how the PHARs are build, so now you need to take three different potential class names into account for the Exporter.... See: Yoast/PHPUnit-Polyfills#161 for how I solved this in the PHPUnit Polyfills.

use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Traversable;

Expand Down Expand Up @@ -107,7 +108,9 @@ public function evaluate($other, string $description = '', bool $returnResult =
*/
public function toString(): string
{
return 'has the subset ' . $this->exporter()->export($this->subset);
$exporter = method_exists($this, 'exporter') ? $this->exporter() : new Exporter();

return 'has the subset ' . $exporter->export($this->subset);
}

/**
Expand Down
Loading