test: skip stub-driven abilities load-order simulation under real WordPress (#2620)#2625
Merged
Conversation
The three abilities load-order smoke tests (categories, image-template, send-email) drive ensure_registered() through its doing_action / did_action / post-action timing states by stubbing the WordPress lifecycle functions. Those stubs are only installed when the real functions are absent (`if ( ! function_exists() )`), so under the wp-codebox host-smoke backend — which runs every tests/*-smoke.php inside a real WordPress — the stubs are inert: `doing_action( 'wp_abilities_api_*_init' )` reflects the live (false) dispatch state, the simulation cannot force state 1, and the "register immediately" assertion fails, exiting non-zero and aborting the whole host-smoke phase (it stops on the first alphabetical failure). Guard the stub-driven behavioral simulation behind `! defined( 'WPINC' )` (the established real-WP detector used by agent-conversation-runtime-policy-smoke). The source-string assertions — which lock the actual contract (unconditional category/ability registration call site + lifecycle-safe branches) — still run in every backend, and the behavioral path remains fully exercised in the pure-PHP / PHPUnit context. No production code change. Closes #2620
Contributor
Homeboy Results —
|
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.
Summary
The
homeboy / Testhost-smoke phase crashes onabilities-categories-load-order-smoke.php(run-phpexit 255 /state 1assertion failure), which aborts the entire host-smoke run — it stops on the first alphabetical failure. Two sibling tests (abilities-image-template-load-order-smoke.php,abilities-send-email-load-order-smoke.php) have the identical defect and would crash next, so all three are fixed here.Closes #2620
Root cause
These three smoke tests drive
ensure_registered()through its three timing states (doing_action→ register now,! did_action→ hook, post-action → no-op) by stubbing the WordPress lifecycle functions (doing_action,did_action,add_action,wp_register_ability_category/wp_register_ability). The stubs are installed only when the real functions are absent:The wp-codebox host-smoke backend runs every
tests/*-smoke.phpinside a real WordPress, where all those functions already exist — so the stubs are never installed and are inert. The simulation sets$state->doing = trueto fake "the init action is firing", but realdoing_action( 'wp_abilities_api_categories_init' )returnsfalseduring the test, so categories never register immediately and the state 1 assertion fails →exit(1)→ host-smoke aborts.This is a test-harness incompatibility, not a production regression. The runtime registration logic is correct (and is the same code that boots categories on every request).
Fix
Guard the stub-driven behavioral simulation behind
! defined( 'WPINC' )— the established real-WP detector already used byagent-conversation-runtime-policy-smoke.php. Under real WordPress the test runs only the source-string assertions (which lock the real contract: unconditional registration call site + lifecycle-safedoing_action/did_action/no-op branches) and exits 0. In the pure-PHP / PHPUnit context the full behavioral simulation still runs.No production code changed — test-only.
Verification
Each of the three tests validated in both modes:
WPINCdefined)