Skip to content

test: cover cleanup without presence table - #263

Open
floze-the-genius wants to merge 2 commits into
WordPress:mainfrom
floze-the-genius:test/262-cleanup-no-table
Open

test: cover cleanup without presence table#263
floze-the-genius wants to merge 2 commits into
WordPress:mainfrom
floze-the-genius:test/262-cleanup-no-table

Conversation

@floze-the-genius

@floze-the-genius floze-the-genius commented Aug 11, 2026

Copy link
Copy Markdown

Adds regression coverage for the cleanup() early return when the presence table is unavailable. The test uses the established database-version filter pattern and verifies both the zero-deletion success message and that no confirmation prompt is shown.

Fixes #262

Testing

  • focused PHPUnit: 1 test, 2 assertions
  • full single-site PHPUnit: 187 tests, 417 assertions, 5 expected multisite skips
  • PHPCS: 17/17 files clean
  • PHPStan: no errors
  • workflow script tests: 54/54 passed
  • local Playwright E2E: 13/13 passed
  • git diff --check

The new cleanup case also passes in multisite mode. The complete local multisite run has one unrelated failure in test_new_site_is_provisioned_on_initialize_site; it reproduces when run alone, and both that test and its production path are unchanged from main. The authoritative hosted PHP 8.3 multisite job passes.

The hosted Playwright job did not reach E2E tests because wp-env start encountered a runner/network TLS hostname mismatch while Composer fetched a dependency. The equivalent local Playwright suite passes all 13 tests.

Use of AI Tools

AI assistance: Yes
Tool(s): OpenAI Codex
Model(s): GPT-5
Used for: Drafting the issue-prescribed regression test and validation notes, running the relevant project gates, and an additional AI-assisted review. Human maintainer review remains required.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @floze-the-genius.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props iamchitti, joefusco.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.65%. Comparing base (2380263) to head (0f8c40b).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #263      +/-   ##
============================================
+ Coverage     77.55%   77.65%   +0.10%     
  Complexity      178      178              
============================================
  Files            14       14              
  Lines          1974     1974              
============================================
+ Hits           1531     1533       +2     
+ Misses          443      441       -2     
Flag Coverage Δ
multisite 77.65% <ø> (+0.10%) ⬆️
phpunit 76.44% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@josephfusco

Copy link
Copy Markdown
Collaborator

Hey @floze-the-genius thanks for tackling this.

The following contributors have not linked their GitHub and WordPress.org accounts: @floze-the-genius.

To receive proper attribution please associate a WordPress.org account with your GitHub account. Let me know once that's setup and I'll run the props-bot again.

public function test_cleanup_reports_zero_without_a_table() {
add_filter( 'option_wp_presence_db_version', '__return_zero' );

$this->command->cleanup( array(), array( 'yes' => true ) );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The confirm assertion here doesn't actually test the no-table code path.

cleanup() skips confirm() for two reasons - either the table is missing, or 'yes' => true was passed. This test passes 'yes' => true, so confirm() is already skipped, regardless of whether the no-table path fires. I confirmed this by removing the no-table early return from cleanup() and rerunning. It still passed.

The "yes flag skips confirm" behavior is already covered here test_cleanup_skips_the_prompt_with_the_yes_flag .

Suggested change
$this->command->cleanup( array(), array( 'yes' => true ) );
$this->command->cleanup( array(), array() );

@josephfusco josephfusco added [Type] Enhancement A suggestion for improvement of an existing feature Infrastructure Issues for the repository infrastructure [Area] CLI Issues for the WP-CLI commands php Pull requests that update php code Needs WP.org Link Author hasn't linked a WordPress.org account yet — confirm before merging so props credit correctly labels Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] CLI Issues for the WP-CLI commands Infrastructure Issues for the repository infrastructure Needs WP.org Link Author hasn't linked a WordPress.org account yet — confirm before merging so props credit correctly php Pull requests that update php code [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage for the no-table branch in WP_Presence_CLI_Command::cleanup()

3 participants