-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compare with default wp-env where everything is bundled #2
base: main
Are you sure you want to change the base?
Conversation
@@ -34,6 +34,6 @@ | |||
"format:docs": "wp-scripts lint-md-docs --fix", | |||
"test": "npm-run-all2 test:*", | |||
"test:workspaces": "npm run test --workspaces --if-present", | |||
"test:phpunit": "wp-env run tests-cli composer test" | |||
"test:phpunit": "wp-env run tests-cli --env-cwd=tools phpunit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the bundled phpunit
simply fails:
An error occurred inside PHPUnit.
Message: Call to undefined method PHPUnit\Framework\TestSuite::empty()
Location: /home/USERNAME/.composer/vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/TestSuiteMapper.php:48
#0 /home/USERNAME/.composer/vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(75):
...
if ( is_readable( $wp_env_tests_dir . '/wp-tests-config.php' ) ) { | ||
putenv( sprintf( 'WP_PHPUNIT__TESTS_CONFIG=%s/wp-tests-config.php', $wp_env_tests_dir ) ); | ||
} | ||
$wp_tests_dir = getenv( 'WP_TESTS_DIR' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we rely on the bundled WP PHPUnit testing library instead of pulling in a known version from https://github.com/wp-phpunit/docs
This will change with every version of WP core we require in wp-env.json
which could lead to breaking changes.
@@ -7,7 +7,6 @@ | |||
"request": "launch", | |||
"port": 9003, | |||
"pathMappings": { | |||
"/var/www/html": "${workspaceFolder}/wordpress", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDEs no longer have access to WP core files for autocomplete and debugging.
This is a diff to illustrate the suggested default setup using only the bundled WP core, PHPunit testing library, etc.
Issues
Code editors no longer have access to WP core files so no autocomplete, debug breakpoints, etc.
The bundled
phpunit
is not functional:The wp-env environment doesn't include
yoast/phpunit-polyfills
so that has to be required at the project level. Requiring this package also pulls in a version of phpunit which conflicts with the bundled phpunit at/home/USERNAME/.composer/vendor/phpunit/...
The bundled
phpunit
is useless due to the above. Each project must call their localvendor/bin/phpunit
to run the tests. What's the purpose of the bundledphpunit
if it can't be used at all?A different version of WP PHPunit library is pulled with every version of WP core defined in
.wp-env.json
which leads to unexpected testing behaviour.