Flush dynamically scheduled core cron events in Behat tests#148
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
In WordPress 6.3.0+, WordPress core introduced the
wp_delete_temp_updater_backupscron hook. This hook is dynamically scheduled fortime()(now) whenWP_Upgraderis first instantiated on a site (which occurs whenwp_version_checkexecutes and finds update/translation offers fromapi.wordpress.org).During
wp cron event run --allon fresh installs,wp_delete_temp_updater_backupsis scheduled mid-execution and is not included in the initial snapshot of events executed byrun --all. As a result, it remains queued as duenow, causing subsequentwp cron event run --due-nowassertions in Behat tests to fail when they expect 0 due events.This PR adds a
wp cron event run --due-nowstep to flush any dynamically scheduled core cron events before asserting 0 due events.This makes the tests more resilient as they were temporarily failing because wp-cli/wp-cli-tests#337 wasn't merged yet after the most recent minor release.
Summary by CodeRabbit
--due-nowresults by accepting successful execution totals instead of requiring an exact zero-event message.