File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1666,3 +1666,35 @@ Feature: WP-CLI Commands
16661666 """
16671667 core custom-subcommand
16681668 """
1669+
1670+ Scenario : An activated plugin should successfully trigger custom commands on the cli_init action.
1671+ Given a WP installation
1672+ And a wp-content/plugins/custom-command/custom-cmd.php file:
1673+ """
1674+ <?php
1675+ // Plugin Name: Custom Command
1676+
1677+ add_action( 'cli_init', function() {
1678+ require_once plugin_dir_path( __FILE__ ) . '/class-custom-command.php';
1679+ $command = new Custom_Command();
1680+ WP_CLI::add_command( 'custom', array( $command, 'do_custom_command' ) );
1681+ } );
1682+ """
1683+ And a wp-content/plugins/custom-command/class-custom-command.php file:
1684+ """
1685+ <?php
1686+ class Custom_Command extends WP_CLI_Command {
1687+ /**
1688+ * Tell the whole world!
1689+ */
1690+ public function do_custom_command() {
1691+ WP_CLI::success( "This command doesn't really do much, does it?" );
1692+ }
1693+ }
1694+ """
1695+ And I run `wp plugin activate custom-command`
1696+ When I run `wp custom --help`
1697+ Then STDOUT should contain:
1698+ """
1699+ wp custom
1700+ """
You can’t perform that action at this time.
0 commit comments