Skip to content

Support PHPUnit 13#1629

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

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

Conversation

@dbebawy
Copy link
Copy Markdown

@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.
@aldemeery
Copy link
Copy Markdown

Any updates here? @dbebawy

@dbebawy
Copy link
Copy Markdown
Author

dbebawy commented Feb 16, 2026

Any updates here? @dbebawy

I've submitted the PR but it's waiting on an approval from a maintainer.

@nunomaduro
Copy link
Copy Markdown
Member

PHPUnit 13 will be used by Pest 5 that is under development.. Meanwhile, just use Pest 4.

@nunomaduro nunomaduro closed this Feb 18, 2026
@aldemeery
Copy link
Copy Markdown

@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?

@ipontt
Copy link
Copy Markdown

ipontt commented Mar 19, 2026

@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 key.

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/dbebawy/pest"
        },

Then you just have to require pestphp/pest with dev-<your-branch-name-here> instead of ^4.0 as the constraint. Github might complain about API rates, but you can just get around this by creating a token and saving it in your auth.json file when prompted to do so.

Again, just do this if you're sure about it. It's a dirty, temporary fix at best.

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.

4 participants