-
Notifications
You must be signed in to change notification settings - Fork 4k
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: correct multisite support #22613
Env: correct multisite support #22613
Conversation
Size Change: +13.9 kB (1%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
Have you tried just hardcoding |
Yeah, I also think that would solve the original problem, but we probably wouldn’t want it turned on all the time. The reason we went with this route is that there could be other things that should be configured before loading settings, so it might be hard to pick all of those out by hand to define early. Additionally, loading settings twice causes all of the redeclared constant warnings you see running phpunit in wp-env. We would still probably not want to load the file twice |
Note that the multisite tests are failing in this PR even though travis is green. This is because the phpunit command exits with 0 even though the database connection failed. |
After some debugging it looks like wp_die is called at |
Could this be fixed in 1 In that it's what |
@noisysocks I think this is a shortcoming of wp-phpunit, but it's an explicit one. It has us set the path to our own config file, and then it loads our config file in its own config file |
see the "why" section here: https://github.com/wp-phpunit/docs#overview
|
I'm also conflicted here because so much about phpunit is tied to the environment (wp-env), but wp-env's primary goal isn't to support 3rd party deps like phpunit. To make it straightforward to run phpunit, we have to modify wp-env, but that means accepting phpunit under wp-env's umbrella even though it's currently a composer dependency of the Gutenberg plugin. |
WP also ships with a separate
I think |
Thanks! That's helpful 🙂
Yeah... are we conflating Gutenberg and |
It's not really relevant to this PR, but I'm curious what changes to WordPress would make it play nicer with |
why not? As we've seen already, setting up phpunit is a pain, and it's good for us to support unit-tested code in the WordPress ecosystem. It'd be great to make it less of a pain, IMO. I just wonder if wp-env should be trying to absorb this complexity since the phpunit setup is so closely tied to the other configuration code in wp-env |
Pushed a commit to set the additional test constants that multisite needs.
I think a big thing is that |
Hm, still seeing the database connection here: https://travis-ci.com/github/WordPress/gutenberg/jobs/339864292 |
Yeah it's strange. Before that commit, the tests blew up entirely for me, and after that commit they work. But that seemed to have no effect in travis? |
I was just wondering if that approach at least gets the multisite tests to pass. |
Theoretically, it shouldn't change behavior, since wp-phpunit does define the constant if it exists as an environment variable. We've confirmed that behavior works, but it's worth a shot |
I think a good first step here is to make sure the multisite test fails if:
If either of these fail, we currently don't know about it without looking at the logs since travis passes. |
ff2ba0c
to
ed4471f
Compare
AFAICT, we are at the point that the multisite tests are actually passing and working on multisite. The issue is the db error output which I think is happening because it isn't able to find the right current site. |
Another oddity is that if I add a wp_die call in |
the current failure is a flakey e2e test, not php. Don't let that fool you into thinking multisite php tests are working because they aren't |
Was finally able to get an error message to appear
We did add this constant though in |
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs git-svn-id: https://develop.svn.wordpress.org/trunk@47904 602fd350-edb4-49c9-b593-d223f7449a82
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs git-svn-id: https://develop.svn.wordpress.org/trunk@47904 602fd350-edb4-49c9-b593-d223f7449a82
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs Built from https://develop.svn.wordpress.org/trunk@47904 git-svn-id: http://core.svn.wordpress.org/trunk@47678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs Built from https://develop.svn.wordpress.org/trunk@47904 git-svn-id: https://core.svn.wordpress.org/trunk@47678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
cc @epiqueras @noisysocks we have the tests passing now. Just had to copy the test config values to the override file! should be good for a review 👍 |
Great work here! |
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs git-svn-id: https://develop.svn.wordpress.org/trunk@47904 602fd350-edb4-49c9-b593-d223f7449a82
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user. See: WordPress/gutenberg#22613 Fixes: #50251 Props: TimothyBlynJacobs git-svn-id: https://develop.svn.wordpress.org/trunk/tests/phpunit/includes@47904 602fd350-edb4-49c9-b593-d223f7449a82
Description
So it turns out that wp-env isn't really doing multisite tests right now. After some debugging by @TimothyBJacobs, we discovered that our wp-config.php requires wp-settings.php before MULTISITE is defined to true. This means that wp-phpunit can't redefine that constant to true. Normally, wp-phpunit would define the constant to true if there is an existing MULTISITE env variable and then load the wp-settings.php file.
Basically, wp-settings.php is being loaded twice: once by us and once by wp-phpunit. We can solve the multisite issue (and other issues, I'm sure) by not loading it ourselves when running wp-phpunit. I've done this by creating a copy of wp-config.php which does not load wp-settings.php when wordpress is initialized by wp-env.
One nice bonus is that this is also the cause of our "redeclared constant" errors. Before this PR, you'd see 3-4 of those when running phpunit, and now there are none. This makes a lot of sense if these files have been loaded twice!
Unfortunately, after fixing this, I am getting the following error running multisite tests. This error does not appear for single site test runs.
How has this been tested?
Screenshots
Types of changes
bug fix
Checklist: