Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions includes/class-rfsd-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Rfsd_Cli {
/**
* Purge all cached FAQ output.
*
* @subcommand purge-transients
* @alias purge_transients
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
*/
Expand All @@ -36,6 +39,9 @@ public function purge_transients( $args, $assoc_args ) { // phpcs:ignore Generic
* Process invalidation queue via CLI.
* Usage: wp rfsd process-queue --limit=1000
*
* @subcommand process-queue
* @alias process_queue
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
*/
Expand All @@ -49,6 +55,9 @@ public function process_queue( $args, $assoc_args ) {
/**
* Show queue length
*
* @subcommand queue-info
* @alias queue_info
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
*/
Expand Down
24 changes: 24 additions & 0 deletions tests/php/test-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,28 @@ public function test_queue_info() {
$this->cli->queue_info( array(), array() );
$this->assertSame( 'Queue length: 2', $this->last_success() );
}

/**
* WP-CLI names a subcommand after its method unless @subcommand says otherwise; the readme documents the
* hyphenated names.
*
* @dataProvider subcommand_provider
*
* @param string $method Method name.
* @param string $subcommand Documented subcommand.
*/
public function test_subcommands_use_the_documented_names( $method, $subcommand ) {
$doc = ( new ReflectionMethod( 'RFSD\Rfsd_Cli', $method ) )->getDocComment();
$this->assertStringContainsString( "@subcommand {$subcommand}\n", $doc );
$this->assertStringContainsString( "@alias {$method}\n", $doc, 'The underscore name keeps working.' );
$this->assertStringContainsString( "`wp rfsd {$subcommand}", file_get_contents( RFSD_PLUGIN_DIR . 'readme.txt' ) );
}

public function subcommand_provider() {
return array(
array( 'purge_transients', 'purge-transients' ),
array( 'process_queue', 'process-queue' ),
array( 'queue_info', 'queue-info' ),
);
}
}
Loading