Skip to content

28: Prove the notice was there before asserting it is gone - #42

Open
nikolaystrikhar wants to merge 1 commit into
27-incorrect-usage-assertionsfrom
28-notices-test-controls
Open

28: Prove the notice was there before asserting it is gone#42
nikolaystrikhar wants to merge 1 commit into
27-incorrect-usage-assertionsfrom
28-notices-test-controls

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: the four Notices test files prove state exists before asserting it is gone, cover the store's option_name() seam, pin the capability-before-read ordering, and add the multisite scope test the queue never had.

Usage:

$this->assertNotFalse( get_site_option( $name ), 'The row is there to be cleared.' );
$store->clear();
$this->assertFalse( get_site_option( $name ) );

Why this way:

An assertFalse after a clear passes for a store that never wrote. Three tests had no in-test proof the row existed; one in the same file already did it correctly, so the shape was there to copy.

The replacement-store double overrode everything except the method under test. Notices\Writer::option_name() delegates to the store — that is the seam a host moving the queue relies on — but a writer composing the name from Config::get_option_name() instead passed the file.

Network scope was green either way. No test in the suite called switch_to_blog(), so swapping get_site_option() for get_option() broke nothing. It now creates a second site and reads the queue from it.

The capability check guards the clearing, not just the drawing. Nothing asserted it runs before the store is read, so a user who may not see the queue could have destroyed it.

Three clear-then-assertFalse tests never established the row existed, so a
store that wrote nothing passed them. The renderer's not-called assertion had
its control in a sibling test. The replacement-store test overrode all(), put()
and clear() but not option_name(), so a writer composing the name itself --
instead of delegating, which is the documented seam -- passed.

Adds the multisite scope neither option had: the queue is written, a second
site is created, and switch_to_blog() finds it still there. Swapping the store
to get_option()/update_option() now fails the multisite leg, where before it
was green on both.

Also pins that the capability is checked before the store is read. The check
guards the clearing as much as the drawing, and nothing said so.
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