Skip to content

Support PHPUnit 13#1629

Open
dbebawy wants to merge 1 commit intopestphp:4.xfrom
dbebawy:phpunit-13-support
Open

Support PHPUnit 13#1629
dbebawy wants to merge 1 commit intopestphp:4.xfrom
dbebawy:phpunit-13-support

Conversation

@dbebawy
Copy link

@dbebawy dbebawy commented Feb 10, 2026

Summary

Widens the PHPUnit version constraint to accept ^13.0 alongside ^12.5.8, and updates the conflict rule from >12.5.8 to >13.1.

Code audit

I audited every PHPUnit class/interface that Pest imports across src/:

  • Event system: All event classes (BeforeFirstTestMethodErrored, AfterLastTestMethodErrored, Errored, Failed, Skipped, ConsideredRisky, MarkedIncomplete) and their subscriber interfaces retain the same PHPUnit\Event\Test namespace 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.
  • Internal APIs: 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.
  • Removed APIs not used by Pest: Assert::isType(), assertContainsOnly(), containsOnly(), #[RunClassInSeparateProcess], --dont-report-useless-tests — none are used in Pest's source.

Dependency note

nunomaduro/collision ^8.8.3 currently conflicts with phpunit/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-tests CLI option
  • PHP 8.3 support

None of these affect Pest's runtime code.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant