PHP unit tests: Activate WC in the bootstrap rather than just loading files #47336
+13
−11
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.
Changes proposed in this Pull Request:
Recently this test started failing for all PRs. Investigating, I noticed that the plugin used in the test, Facebook for WooCommerce, had released a new version two days before with this changelog entry:
After checking the internal state of things during the course of the unit test, I determined that the plugin was, in fact, installed, but that the activation call was failing with the message "The requested plugin
facebook-for-woocommerce
could not be activated." Looking further, I realized that in our unit test environment, we have been loading all the code for the WooCommerce plugin directly, and it is not actually considered "activated" by WordPress.The main benefits of activating the plugin in this context are that the plugin slug will be included in the
active_plugins
option in wp_options, and the activation process will produce an error if any unexpected output is generated (meaning error messages or other content gets printed to the output buffer).This PR is a bit of an experiment to see how the entire test suite fairs if we actually activate the WooCommerce plugin rather than just loading its code directly.
How to test the changes in this Pull Request:
See if all the tests still pass.