-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
PHP Unit Tests: Set theme to TT1 Blocks #30686
Conversation
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
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? |
Closing in favor of #30830, which seems like a better solution (and doesn't cause existing unit tests to fail 😬 ) |
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.json
file -- so we're erroneously cachingfalse
as 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 cachedfalse
value.The fix is to set
$GLOBALS['wp_tests_options']
values forstylesheet
andtemplate
, 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-blocks
in all cases, andtheme_has_support()
should returntrue
every 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?