| name | status | update | version |
| zombieland | active | none | 0.1-alpha |
- When I run `wp plugin delete zombieland`
- Then the {PLUGIN_DIR}/zombieland file should not exist
-
- When I try `wp plugin status zombieland`
+ When I try `wp plugin uninstall zombieland`
Then the return code should be 1
And STDERR should contain:
"""
- Error: The plugin 'zombieland' could not be found.
+ The plugin is active.
"""
+ When I run `wp plugin deactivate zombieland`
+ Then STDOUT should not be empty
+
+ When I run `wp plugin uninstall zombieland`
+ Then STDOUT should contain:
+ """
+ Success: Uninstalled 'zombieland' plugin.
+ """
+ And the {PLUGIN_DIR}/zombieland file should not exist
+
+ When I try the previous command again
+ Then the return code should be 1
+ And STDERR should contain:
+ """
+ The plugin 'zombieland' could not be found.
+ """
Feature: Manage WordPress themes and plugins
- Scenario Outline: Upgrading a theme or plugin
+ Scenario Outline: Installing, upgrading and deleting a theme or plugin
Given a WP install
And I run `wp <type> install <item> --version=<version>`
When I run `wp <type> status <item>`
Then STDOUT should contain:
"""
- Version: <version> (Update available)
+ Status: Inactive
+ Version: <version> (Update available)
"""
When I run `wp <type> update <item>`
(Update available)
"""
+ When I run `wp <type> delete <item>`
+ Then STDOUT should contain:
+ """
+ Success: Deleted '<item>' <type>.
+ """
+
+ When I try `wp <type> status <item>`
+ Then the return code should be 1
+ And STDERR should not be empty
+
Examples:
| type | item | version |
| theme | p2 | 1.0.1 |
* @synopsis <plugin> [--version=<version>]
*/
function update( $args, $assoc_args ) {
+ list( $basename ) = $this->parse_name( $args );
+
if ( isset( $assoc_args['version'] ) && 'dev' == $assoc_args['version'] ) {
- $this->delete( $args, array(), false );
+ $this->_delete( $basename, false );
$this->install( $args, $assoc_args );
} else {
- list( $basename ) = $this->parse_name( $args );
-
$was_active = is_plugin_active( $basename );
$was_network_active = is_plugin_active_for_network( $basename );
uninstall_plugin( $file );
- if ( !isset( $assoc_args['no-delete'] ) )
- $this->delete( $args );
+ if ( isset( $assoc_args['no-delete'] ) )
+ return;
+
+ if ( $this->_delete( $file ) ) {
+ WP_CLI::success( sprintf( "Uninstalled '%s' plugin.", $name ) );
+ }
}
/**
*
* @synopsis <plugin>
*/
- function delete( $args, $assoc_args = array(), $exit_on_error = true ) {
+ function delete( $args, $assoc_args = array() ) {
list( $file, $name ) = $this->parse_name( $args );
- $plugin_dir = dirname( $file );
- if ( '.' == $plugin_dir )
- $plugin_dir = $file;
-
- $command = 'rm -rf ' . path_join( WP_PLUGIN_DIR, $plugin_dir );
-
- return WP_CLI::launch( $command, $exit_on_error );
+ if ( $this->_delete( $file ) ) {
+ WP_CLI::success( sprintf( "Deleted '%s' plugin.", $name ) );
+ }
}
/**
return $name;
}
+
+ private function _delete( $file ) {
+ $plugin_dir = dirname( $file );
+ if ( '.' == $plugin_dir )
+ $plugin_dir = $file;
+
+ $command = 'rm -rf ' . path_join( WP_PLUGIN_DIR, $plugin_dir );
+
+ return ! WP_CLI::launch( $command );
+ }
}
WP_CLI::add_command( 'plugin', 'Plugin_Command' );
*/
function delete( $args ) {
$theme = $this->parse_name( $args );
+ $theme_slug = $theme->get_stylesheet();
if ( $this->is_active_theme( $theme ) ) {
WP_CLI::error( "Can't delete the currently active theme." );
}
- $r = delete_theme( $theme->get_stylesheet() );
+ $r = delete_theme( $theme_slug );
if ( is_wp_error( $r ) ) {
WP_CLI::error( $r );
}
- WP_CLI::success( "$theme->name theme deleted." );
+ WP_CLI::success( sprintf( "Deleted '%s' theme.", $theme_slug ) );
}
/**