PHP Unit Tests: Set theme to TT1 Blocks#30686
Closed
ockham wants to merge 1 commit into
Closed
Conversation
|
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
This was referenced Apr 9, 2021
Contributor
Author
Copied here for convenience: PHP Unit test failures@nosolosw Can you tell from a glance at these if it's legit to update tests to add the missing properties? |
Contributor
Author
|
Closing in favor of #30830, which seems like a better solution (and doesn't cause existing unit tests to fail 😬 ) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #30478. Alternative (or maybe complementary) to #30479.
As explained in #30478, we're caching the return value of
WP_Theme_JSON_Resolver::theme_has_support().This seems to work fine in a "normal" WordPress environment; however, it seems to pose a problem for unit tests:
WP_Theme_JSON_Resolver::theme_has_support()is first called while the current theme is still set to the default theme -- which of course doesn't have anexperimental-theme.jsonfile -- so we're erroneously cachingfalseas return value forWP_Theme_JSON_Resolver::theme_has_support().Even if an individual unit test later sets the current theme to one that has an
experimental-theme.json,WP_Theme_JSON_Resolver::theme_has_support()will continue to return the cachedfalsevalue.The fix is to set
$GLOBALS['wp_tests_options']values forstylesheetandtemplate, which are evaluated bywp-phunit's bootstrap to set a few options before loading WordPress.How has this been tested?
See #30478 for instructions on how to repro the issue on
trunk.Then, check out this branch, and apply the patch on top of it.
Patch
Then, run
This time, the stylesheet output should correctly be
/var/www/html/wp-content/themes/tt1-blocksin all cases, andtheme_has_support()should returntrueevery time:Output
However, this patch seems to break a few of the other PHP unit tests -- which might need an update to correctly reflect properties of TT1 Blocks?