-
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
Fix phpunit failures #51950
Fix phpunit failures #51950
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help on this one!
…specific development mode. In recent releases, WordPress core added several instances of cache usage around specific files. While those caches are safe to use in a production context, in development certain nuances apply for whether or not those caches make sense to use. Initially, `WP_DEBUG` was used as a temporary workaround, but it was clear that a more granular method to signify a specific development mode was required: For example, caches around `theme.json` should be disabled when working on a theme as otherwise it would disrupt the theme developer's workflow, but when working on a plugin or WordPress core, this consideration does not apply. This changeset introduces a `WP_DEVELOPMENT_MODE` constant which, for now, can be set to either "core", "plugin", "theme", or an empty string, the latter of which means no development mode, which is also the default. A new function `wp_get_development_mode()` is the recommended way to retrieve that configuration value. With the new function available, this changeset replaces all existing instances of the aforementioned `WP_DEBUG` workaround to use `wp_get_development_mode()` with a more specific check. Props azaozz, sergeybiryukov, peterwilsoncc, spacedmonkey. Fixes #57487. git-svn-id: https://develop.svn.wordpress.org/trunk@56042 602fd350-edb4-49c9-b593-d223f7449a82
Hmm, the second part is not correct I think. The only intention of the As far as I understand, the failing Gutenberg tests assume that the logic is not being cached, which isn't guaranteed. I agree those tests would preferably only live in core, but I would suggest one of the two following workarounds:
I'm a bit confused by the change of just setting |
Thanks for the advice @felixarntz I've made a note to return to this after WP 6.3 Beta 1 (which is soon 😄 ) In the meantime, this patch would unblock a lot of work in the next few days. @noisysocks do you think we could merge this in the meantime? |
Thanks for the extra context @felixarntz! You're right, re-reading I'll try one of your suggestions. We can hold off on merging this unless an urgent need comes up. |
Ah. Setting The tests in Gutenberg are written assuming that
It's not anything to do with |
Note also that I think setting |
👍 Maybe I'm overthinking it, but say we remove the tests and also the new constant. What about future additions to say, I guess Gutenberg could do what it always does for compatibility, e.g., create a correspsonding, but altered, function |
Hmm yeah good flag. We can do what you suggest or, maybe better, update Core's implementation of |
I like the cut of your gib |
@noisysocks @ramonjd Thank you for the additional digging, based on the further context you provided the fix here LGTM.
Big +1 from me, would you mind opening a Trac ticket for this? |
Ticket here: https://core.trac.wordpress.org/ticket/58650 Please edit/expand if I've got the details wrong 🙇 |
* Fix phpunit failures * Add comment * Update comment with actual reason this fix works
* Restore sidebar in focus mode on Pattern click through in Browse Mode Library (#51897) Brings back #51492 * [Command center]: Add preferences and keyboard shortcuts commands (#51862) * [Command center]: Add preferences and keyboard shortcuts commands * update labels * [Site Editor]: Fix `library` command path (#51837) * Updating social link attributes (#51997) * Try: Update template titles (#51428) * Update template titles * Fix typo Co-authored-by: Alex Stine <[email protected]> * Revert Index rename * "front page" -> "homepage" * Update 404 Page make more sense given the template appears in the Pages panel too. * Front Page * home title + description * Revert Home name change, and move compat files * separate code for wp versions * update tests --------- Co-authored-by: Alex Stine <[email protected]> Co-authored-by: ntsekouras <[email protected]> * Update text color (#51965) * Modal: Add small top padding to the content so that avoid cutting off the visible outline when hovering items (#51829) * Site Editor: Fix focus cutoff in add template modal * Add padding-top to the modal content * Remove unnecessary padding-top * Remove unnecessary padding-top * Update changelog * Revert top padding from block patterns list * Revert top padding from block patterns list * Remove unnecessary changes * Remove unnecessary changes * Add CSS inline comment * Change padding metrics * Rest API: rename navigation fallback classes from WP_ to Gutenberg_ (#51959) * The `WP_REST_Navigation_Fallback_Controller` class has been committed to core and therefore results in a naming conflict and unit test failures. Ideally `WP_REST_Navigation_Fallback_Controller` should have been named `WP_REST_Navigation_Fallback_Controller_Gutenberg` and extended `WP_REST_Navigation_Fallback_Controller`. But we can conditionally load the file instead. * Renamed WP_Classic_To_Block_Menu_Converter to Gutenberg_Classic_To_Block_Menu_Converter Load WP_REST_Navigation_Fallback_Controller dependencies in load.php * Renamed all 6.3 classes to have the Gutenberg_ prefix. This should avoid compat errors and hopefully some confusion later. * Also rename test files for completeness * Updated deprecation notices to refer to Gutenberg classes * Fix phpunit failures (#51950) * Fix phpunit failures * Add comment * Update comment with actual reason this fix works --------- Co-authored-by: Dave Smith <[email protected]> Co-authored-by: Nik Tsekouras <[email protected]> Co-authored-by: Ramon <[email protected]> Co-authored-by: James Koster <[email protected]> Co-authored-by: Alex Stine <[email protected]> Co-authored-by: Aki Hamano <[email protected]> Co-authored-by: Robert Anderson <[email protected]>
* Fix phpunit failures * Add comment * Update comment with actual reason this fix works
…#52229) * Patterns: Fix setting of sync status for fully synced patterns (#51952) * Add check for sync status of fully to account for bug in 16.1 release * Fix phpunit failures (#51950) * Fix phpunit failures * Performance tests: configure as a production environment (#52016) --------- Co-authored-by: Aaron Robertshaw <[email protected]> Co-authored-by: Robert Anderson <[email protected]> Co-authored-by: André <[email protected]>
* Fix phpunit failures * Add comment * Update comment with actual reason this fix works
Fix the phpunit failures in
trunk
.All but one of the failures were from Gutenberg phpunit tests that one way or the other call into Core's global styles and settings functionality e.g.wp_get_global_settings
. These functions will cache their results unlessWP_DEVELOPMENT_MODE
is set to'theme'
or if Core detects that the Core unit tests are running via theWP_RUN_CORE_TESTS
flag. Since Gutenberg is testing Core functionality here, it is de facto performing the role of Core unit tests, and so the fix is to setWP_RUN_CORE_TESTS
. See WordPress/wordpress-develop@4a16702#r119747488.edit: Nope! All but one of the failures are to do with
wp_theme_has_theme_json
caching its return value unlessWP_RUN_CORE_TESTS
is set. See #51950 (comment).One failure (
test_get_template_hierarchy
) is due to an issue where a test taxonomy is registered inwpSetUpBeforeClass
and notset_up
. This causes issues because theswitch_theme
inset_up
will clobber the taxonomies. I note that when these tests were ported to Core this was addressed and we're not usingwpSetUpBeforeClass
there.A lot of these tests, I think, don't belong in Gutenberg anymore. They should have been removed when the functionality that they test were moved from Gutenberg to Core. It doesn't make sense to have tests in Gutenberg that test Core functionality. Alternatively, the changes that were made to the PHP test code before being merged to Core should have been brought back to the plugin. For example note how different
Tests_Block_Template_Utils
looks in Core versus in Gutenberg.