Skip to content
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

Env: wp-phpunit not in sync with mapped WordPress version #23171

Closed
noahtallen opened this issue Jun 15, 2020 · 5 comments · Fixed by #41780
Closed

Env: wp-phpunit not in sync with mapped WordPress version #23171

noahtallen opened this issue Jun 15, 2020 · 5 comments · Fixed by #41780
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env [Type] Bug An existing feature does not function as intended

Comments

@noahtallen
Copy link
Member

noahtallen commented Jun 15, 2020

Describe the bug
A few days ago, we noticed phpunit failures in Travis. This was because a change was merged to wordpress core which was propagated to wp-env. Unfortunately, wp-phpunit (the dep we use to install wp phpunit test lib) is pinned at the test code in the last WP version, so the same changes did not propogate to it.

Essentially, the WordPress version running on the wp-env container is not in sync with the version the wp-phpunit test lib expects.

Link to discussion in make WordPress slack (requires signup): https://wordpress.slack.com/archives/C02QB2JS7/p1591979580086000

Solution

The solution we have discussed (cc @TimothyBJacobs, @joemcgill) is to do something like this:

  1. Detect the current WordPress version. If wordpress-develop, bail since the test lib is already mapped.
  2. Use that WordPress version to generate a ref to wordpress-develop svn which contains the test-lib in sync with the current WP source code. (We can use wp-cli as a basis for this code.)
  3. Download tests/phpunit/includes and tests/phpunit/data (either inside the docker image or in ~/.wp-env/$hash/)
  4. Map those to the correct location in the phpunit Docker service.
  5. Make sure that the phpunit tests reference this code for the test lib.

One benefit of this approach is that no one will have to worry about installing a wp-phpunit dep, which makes phpunit much more accessable in wp-env.

@timnolte
Copy link
Contributor

timnolte commented Sep 9, 2020

I'm using a source dependency of wordpress-develop in my project and I'd like to use this Install with the Docker test environment to run PHP Unit. Based on that Slack documentation it seems like this might not be possible OOTB currently. Is that correct?

@noahtallen
Copy link
Member Author

Hm. I'm not exactly sure how to do that, but really the only thing that wp-phpunit does is make the WordPress tests library available inside of docker. you currently need to write most everything else yourself (like the config file and bootstrap file). So if your wordpress source includes the tests library, then I think it's just a matter of loading the tests lib from the right location.

@timnolte
Copy link
Contributor

What I'd like to see is have PHPUnit available inside the wp-env test Docker container.

@noahtallen
Copy link
Member Author

Why not use the phpunit service?

image: 'wordpressdevelop/phpunit:${LOCAL_PHP-latest}',
depends_on: [ 'tests-wordpress' ],
volumes: [
...testsMounts,
'phpunit-uploads:/var/www/html/wp-content/uploads',
],
environment: {
LOCAL_DIR: 'html',
WP_PHPUNIT__TESTS_CONFIG:
'/var/www/html/phpunit-wp-config.php',
},
},

Or at least, what is that missing for you? It should pick up on any sources or configuration mapped to the tests volume, and I think it would use the same database

@timnolte
Copy link
Contributor

@noahtallen now that I'm looking through that build script for Docker and seeing how it's used in Gutenberg as well I have a better clue how to make use of the phpunit container. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env [Type] Bug An existing feature does not function as intended
Projects
None yet
2 participants