-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Utilize WordPress PHPUnit Test Library Included By wp-env
#41852
Merged
noahtallen
merged 8 commits into
WordPress:trunk
from
ObliviousHarmony:enhance/migrate-phpunit
Jul 15, 2022
Merged
Utilize WordPress PHPUnit Test Library Included By wp-env
#41852
noahtallen
merged 8 commits into
WordPress:trunk
from
ObliviousHarmony:enhance/migrate-phpunit
Jul 15, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -31,8 +31,7 @@ | |||
"phpcompatibility/php-compatibility": "^9.3", | |||
"wp-coding-standards/wpcs": "^2.2", | |||
"sirbrillig/phpcs-variable-analysis": "^2.8", | |||
"wp-phpunit/wp-phpunit": "^5.4", | |||
"phpunit/phpunit": "^8.5", | |||
"phpunit/phpunit": "^6.5", |
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.
I chose 6.5 here because of the stated requirements for the minimum PHP version. I wanted a version that was compatible with more versions of PHP.
We're going to be running PHPUnit tests using the in-container test files. We will no longer need `wp-phpunit/wp-phpunit`.
In order to work on PHP 8, we must use the methods for setUp(), tearDown(), setUpBeforeClass(), tearDownAfterClass(). This commit replaces those with polyfill versions.
This commit replaces the `run phpunit` unit test scripts with ones that run using the project's PHPUnit.
noahtallen
reviewed
Jul 15, 2022
noahtallen
added
[Type] Bug
An existing feature does not function as intended
[Tool] Env
/packages/env
labels
Jul 15, 2022
Rather than being heavy-handed and disabling the strict handling of tests that do nothing, we should mark those tests as incomplete.
noahtallen
approved these changes
Jul 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This makes the appropriate changes to move us away from needing
wp-phpunit/wp-phpunit
. In the process, I also found thatYoast/PHPUnit-Polyfills
was not being fully utilized. One of the changes was to change methods likesetUp()
toset_up()
to prevent PHP 8 compatibility issues.In addition, as per #39863, the
phpunit
container does not work on M1 chips. This pull request replaces the usage of thephpunit
container with direct usage ofvendor/bin/phpunit
from Gutenberg.Closes #39863.
Why?
#41780 made it so that there's a version of WordPress' PHPUnit test files available within the
wp-env
container. We should dogfood this implementation and use the test files here.How?
This pull request makes a few changes to methods in order to be compatible with
Yoast/PHPUnit-Polyfills
:This also removes the
wp-phpunit/wp-phpunit
dependency since it's no longer necessary.We also add the
wptests_
database table prefix as we are running the test suite in the tests-wordpress container rather than the phpunit container.Testing Instructions
npm run test-unit-php
and verify that it passes.npm run test-unit-php-multisite
and verify that it passes.