Support PHPUnit 13#1629
Conversation
Widen the PHPUnit version constraint to also accept ^13.0 alongside ^12.5.8. Update the conflict rule accordingly. Code audit of Pest's PHPUnit integration surface: - All PHPUnit Event classes used by Pest (BeforeFirstTestMethodErrored, AfterLastTestMethodErrored, Errored, Failed, Skipped, ConsideredRisky, MarkedIncomplete, and all subscribers) retain the same namespace and API in PHPUnit 13. - testClassName() on errored hook events is NOT among the removed methods (only removed from "called"/"finished" hook events). - Internal APIs (TextUI\Application, Configuration\Registry, TestResult\Facade, CliArguments\Builder, XmlConfigurationFileFinder, XmlConfiguration\DefaultConfiguration, XmlConfiguration\Loader, Util\ExcludeList) all retain their namespaces and method signatures. - None of the removed PHPUnit 13 APIs (Assert::isType(), assertContainsOnly(), containsOnly(), #[RunClassInSeparateProcess], --dont-report-useless-tests) are used by Pest. Note: nunomaduro/collision ^8.8.3 currently conflicts with PHPUnit 13. Collision PR pestphp#342 tracks removing that conflict. Once collision is updated, this constraint will resolve cleanly.
|
Any updates here? @dbebawy |
I've submitted the PR but it's waiting on an approval from a maintainer. |
|
PHPUnit 13 will be used by Pest 5 that is under development.. Meanwhile, just use Pest 4. |
|
@nunomaduro Laravel projects using PHPUnit cannot upgrade to PHPUnit 13 because Collision blocks it. And now with this PR closed, and the Collision PR also closed, there's no way around it. We're basically stuck with PHPUnit 12 until Pest 5 comes out! Which is super weird tbh! Is Pest 5 even coming soon? Or do we have to wait for months? |
If you're positively sure phpunit 13 doesn't have any api changes that would break pest 4, you can use your own fork for now. Composer gives you the freedom to add an entry in your "repositories": [
{
"type": "vcs",
"url": "https://github.com/dbebawy/pest"
},Then you just have to require pestphp/pest with Again, just do this if you're sure about it. It's a dirty, temporary fix at best. |
Summary
Widens the PHPUnit version constraint to accept
^13.0alongside^12.5.8, and updates the conflict rule from>12.5.8to>13.1.Code audit
I audited every PHPUnit class/interface that Pest imports across
src/:BeforeFirstTestMethodErrored,AfterLastTestMethodErrored,Errored,Failed,Skipped,ConsideredRisky,MarkedIncomplete) and their subscriber interfaces retain the samePHPUnit\Event\Testnamespace and API in PHPUnit 13.testClassName(): Still present on errored hook events — PHPUnit 13 only removed it from "called"/"finished" hook events, which Pest doesn't use.TextUI\Application,Configuration\Registry,TestResult\Facade,CliArguments\Builder,XmlConfigurationFileFinder,XmlConfiguration\DefaultConfiguration,XmlConfiguration\Loader,Util\ExcludeList— all retain their namespaces and method signatures in PHPUnit 13.Assert::isType(),assertContainsOnly(),containsOnly(),#[RunClassInSeparateProcess],--dont-report-useless-tests— none are used in Pest's source.Dependency note
nunomaduro/collision ^8.8.3currently conflicts withphpunit/phpunit >=13.0.0. Collision PR #342 tracks adding PHPUnit 13 support there. Once collision updates its conflict list, this constraint will resolve cleanly.The circular dependency (Pest → Collision → PHPUnit 13 blocked → Pest) needs to be broken — this PR breaks it from the Pest side. Collision can then update independently since Pest is only a dev dependency there.
PHPUnit 13 key changes (for reference)
PHPUnit 13 requires PHP 8.4+. Removed APIs:
Assert::isType(),assertContainsOnly(),assertNotContainsOnly(),containsOnly()testClassName()on called/finished hook events (NOT errored events)Configuration::includeTestSuite()/excludeTestSuite()#[RunClassInSeparateProcess]attribute--dont-report-useless-testsCLI optionNone of these affect Pest's runtime code.