Skip to content

Running npm run test:php is broken after wp-env update to wp-env 5.0.0 #7263

@westonruter

Description

@westonruter

Bug Description

With the update to wp-env 5.0.0, running npm run test:php now results in a fatal error. This package update had a backwards-incompatible change as explained in the release notes:

Breaking Changes

  • Removed the WP_PHPUNIT__TESTS_CONFIG environment variable from the phpunit container. This removes automatic support for the wp-phpunit/wp-phpunit Composer package. To continue using the package, set the following two environment variables in your phpunit.xml file or similar: WP_TESTS_DIR="" and WP_PHPUNIT__TESTS_CONFIG="/wordpress-phpunit/wp-tests-config.php".
  • Removed the generated /var/www/html/phpunit-wp-config.php file from the environment.

We didn't catch it via CI because GHA doesn't run Docker to run the tests. When running in the local Docker-based dev environment, however, it is broken.

Expected Behaviour

Running PHPUnit tests, both npm run test:php and npm run test:php:xdebug, should work successfully.

Screenshots

$ npm run test:php

> amp-wp@ test:php /home/westonruter/repos/amp
> wp-env run phpunit 'WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args'

ℹ Starting 'WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args' on the phpunit container. 

Starting aabe871bb4b92d5867707c9f76aa7c03_tests-mysql_1 ... done
Starting aabe871bb4b92d5867707c9f76aa7c03_tests-wordpress_1 ... done

wp_die() called
Message: <p>There has been a critical error on this website.</p><p><a href="https://wordpress.org/support/article/faq-troubleshooting/">Learn more about troubleshooting WordPress.</a></p>
Title: WordPress &rsaquo; Error
Args:
        response: 500
        code: internal_server_error
        exit: 
        back_link: 
        link_url: 
        link_text: 
        text_direction: ltr
        charset: UTF-8
        additional_errors: array (
)

PHP Version

No response

Plugin Version

2.3.0

AMP plugin template mode

Standard, Transitional, Reader

WordPress Version

No response

Site Health

No response

Gutenberg Version

No response

OS(s) Affected

No response

Browser(s) Affected

No response

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingChangeloggedWhether the issue/PR has been added to release notes.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions