Skip to content

wp-env: Incompatible version of phpunit used when a custom phpVersion config value is set #29323

Closed

Description

@coreymckrill

Description

If a custom php version is set using the phpVersion property in the .wp-env.json file, the phpunit container will be provisioned using an image that includes phpunit version 8 or 9, both of which are currently not compatible with the WP unit testing framework.

This only applies if the custom php version is set to 7.2 or higher, but because xdebug is currently breaking the docker build for anything less than 7.2, it's essentially applicable whenever the phpVersion property is used.

This problem doesn't happen when phpVersion isn't set, even though the default php version is 7.4, because in that case the phpunit container image will use the latest tag, which I guess must be pinned to version 7 at the moment.

Step-by-step reproduction instructions

  1. Add "phpVersion": "7.2" to Gutenberg's .wp-env.json file.
  2. Rebuild the containers with npm run wp-env start.
  3. Run npm run test-php.

Expected behaviour

The tests should work, regardless of which php version is set. WP php unit tests shouldn't be using phpunit 8 or above under any circumstances right now.

Actual behaviour

You'll eventually see "Error: Looks like you're using PHPUnit 8.5.14. WordPress requires at least PHPUnit 5.4 and is currently only compatible with PHPUnit up to 7.x.". The unit tests won't complete.

WordPress information

  • WordPress version: trunk
  • Gutenberg version: trunk
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes

Device information

  • Device: Desktop
  • Operating system: MacOS 10.15
  • Browser: Firefox latest

Activity

  1. added a commit that references this issue on Mar 4, 2021
  2. mukeshpanchal27 commented on Sep 26, 2022

    @mukeshpanchal27
    Member

    👋 Is there any update on this? I'm facing similar issue in Performance repo.

  3. youknowriad commented on Aug 23, 2026

    @youknowriad
    Contributor

    Closing as resolved: wp-env no longer runs a separate phpunit container — tests execute inside the WordPress container, so they always use the phpVersion you configured, which eliminates the mismatch this described. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Tool] Env/packages/env[Type] RegressionRelated to a regression in the latest release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions