Skip to content

Expand unit coverage for transient cache behavior and adapter safety guards#5

Merged
MaximillianGroup merged 1 commit into
mainfrom
copilot/analyze-test-coverage
May 26, 2026
Merged

Expand unit coverage for transient cache behavior and adapter safety guards#5
MaximillianGroup merged 1 commit into
mainfrom
copilot/analyze-test-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

This PR improves test coverage in areas that were untested despite being core cache-safety and data-isolation paths. It adds focused unit tests around transient cache lifecycle behavior and adapter guardrails.

  • Coverage expansion: transient cache lifecycle + isolation

    • Added direct tests for StarTransientCache site-scoped set/get/delete behavior.
    • Added multisite isolation coverage to ensure per-site transient keys do not bleed across blog IDs.
    • Added network-transient coverage to verify shared visibility across blogs and proper deletion semantics.
  • Coverage expansion: adapter safety semantics

    • Added test coverage for StarCacheAdapter::add() in WP fallback mode to confirm write-once behavior (no overwrite when key exists).
    • Added guard-path coverage for StarCacheAdapter::flush() to ensure dangerous flush is blocked unless explicitly enabled.
  • Test fixture hardening

    • Reset transient global state in setUp() to prevent cross-test contamination for newly covered paths.
$this->assertTrue(StarCacheAdapter::add('adapter_add', 'first', 30, 'group'));
$this->assertFalse(StarCacheAdapter::add('adapter_add', 'second', 30, 'group'));
$this->assertSame('first', StarCacheAdapter::get('adapter_add', 'group'));

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands PHPUnit unit coverage around two core safety/isolation areas in StarCache: (1) transient caching behavior across site vs network scopes and (2) adapter guardrails for “write-once” semantics and dangerous flush blocking.

Changes:

  • Added unit tests for StarTransientCache set/get/delete behavior, including per-blog isolation and network-transient sharing semantics.
  • Added unit tests for StarCacheAdapter::add() (WP fallback, no-overwrite) and StarCacheAdapter::flush() (blocked unless explicitly enabled).
  • Hardened test isolation by resetting the in-memory transient shim state in setUp().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MaximillianGroup MaximillianGroup merged commit 83447af into main May 26, 2026
1 check passed
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.

3 participants