Skip to content

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

Description

@josephfusco

#261 adds an early return in cleanup() for when the presence table doesn't exist, but doesn't add a test for it — codecov shows 0% patch coverage on those 3 lines as a result.

#256 already established the pattern for simulating this: add_filter('option_wp_presence_db_version', '__return_zero'), then assert on WP_CLI::messages(...). Something like:

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 ) );
    $this->assertSame( array( '0 entries deleted.' ), WP_CLI::messages( 'success' ) );
    $this->assertSame( array(), WP_CLI::messages( 'confirm' ) );
}

Follow-up from #261.

Metadata

Metadata

Labels

Good First IssueIssue particularly suitable to be worked on by new contributorsInfrastructureIssues for the repository infrastructure[Area] CLIIssues for the WP-CLI commands[Type] EnhancementA suggestion for improvement of an existing featurephpPull requests that update php code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions