ampproject / amp-wp

Enable AMP on your WordPress site, the WordPress way.
https://wordpress.org/plugins/amp/
GNU General Public License v2.0
1.79k stars 382 forks source link

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

Closed westonruter closed 1 year ago

westonruter commented 2 years ago

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

thelovekesh commented 1 year ago

QA Passed ✅

On running npm run test:php at the base branch(develop) tests are getting executed as expected inside the wp-env docker instance.

Note: wp-env is also getting used by the Build Test & Measure workflow to run multisite PHPUnit tests, which is also working as expected so far.

image