Skip to content

15: End-to-end suite - #16

Open
nikolaystrikhar wants to merge 1 commit into
14-activation-error-rewritefrom
15-e2e-suite
Open

15: End-to-end suite#16
nikolaystrikhar wants to merge 1 commit into
14-activation-error-rewritefrom
15-e2e-suite

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: ten scenarios driving the whole library against real WordPress — no source files, all test infrastructure.

Usage: the shared fixture trait each load-path test now uses.

use WithBundledPlugins;

$constant = $this->unique_guard_constant();
$file     = $this->make_bundled_plugin( $constant );   // a real file, at a path used exactly once

// …register, resolve, load…

$this->assertTrue( defined( $constant ) );
$this->assertSame( 1, $GLOBALS['absorber_loads'] );

Why this way: the four preconditions are what make this suite mean anything. run_conflict_resolution() no-ops unless the request is an interactive admin GET, and the DEACTIVATE branch no-ops unless the current user can activate_plugins — a suite that establishes neither passes green while exercising nothing, so both are set up explicitly and restored afterwards. That was verified by mutation rather than assumed: flipping the request to POST fails three scenarios. Fixtures get a unique path and a unique guard constant per call because require_once caches by resolved path and define() lasts for the whole process, so a shared fixture makes every test after the first pass whether the load path works or not. exit is never mocked: wp_safe_redirect throws, and every scenario asserts the halt flag against its expectation rather than just asserting a halt, so the seven non-halting paths prove no redirect happened.

One honest limitation: DEFER is a no-op by definition, so its assertions hold whether or not the resolver ran. Its observable half is the load guard, and that is what the scenario tests; the request gate is covered by the other three policies.

Verify: slic run unit and slic run unit --env multisite — 349 tests green on both legs, plus composer test:analysis. The multisite leg is not a formality here: deactivate_plugins() is network-wide and both options are network options.

Ten scenarios covering the load guard, all three conflict policies, run-once
activation, the dependency gate and the re-activation rewrite, against real
active_plugins, real deactivate_plugins() and real options. Only wp_safe_redirect
and wp_get_referer are stubbed; every guard constant is a real define() made by a
real file that was really required.

The four preconditions are the load-bearing part. Conflict resolution no-ops
unless the request is an interactive admin GET, and deactivation no-ops unless
the current user can activate_plugins, so a suite that establishes neither passes
while exercising nothing. Both are set up explicitly and restored afterwards.

WithBundledPlugins writes each fixture at a unique path with a unique guard
constant. require_once caches by resolved path and define() lasts for the
process, so a shared fixture would make every test after the first pass whether
the load path worked or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant