Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/test-cli-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ public function test_cleanup_deletes_every_entry_regardless_of_age() {
$this->assertSame( array( '3 entries deleted.' ), WP_CLI::messages( 'success' ) );
}

/**
* @covers WP_Presence_CLI_Command::cleanup
*/
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() );


$this->assertSame( array( '0 entries deleted.' ), WP_CLI::messages( 'success' ) );
$this->assertSame( array(), WP_CLI::messages( 'confirm' ) );
}

/**
* @covers WP_Presence_CLI_Command::cleanup
*/
Expand Down
Loading