diff --git a/features/plugin-delete.feature b/features/plugin-delete.feature index a0cdb822..8fc3cc9d 100644 --- a/features/plugin-delete.feature +++ b/features/plugin-delete.feature @@ -57,3 +57,32 @@ Feature: Delete WordPress plugins Success: """ And the return code should be 0 + + Scenario: Reports a failure for a plugin that can't be deleted + Given a WP install + + When I run `chmod -w wp-content/plugins/akismet` + And I try `wp plugin delete akismet` + Then STDERR should contain: + """ + Warning: The 'akismet' plugin could not be deleted. + """ + And STDERR should contain: + """ + Error: No plugins deleted. + """ + Then STDOUT should not contain: + """ + Success: + """ + + When I run `chmod +w wp-content/plugins/akismet` + And I run `wp plugin delete akismet` + Then STDERR should not contain: + """ + Error: + """ + Then STDOUT should contain: + """ + Success: + """ diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 97dcd37c..7461b1fb 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -1113,6 +1113,7 @@ public function delete( $args, $assoc_args = array() ) { WP_CLI::log( "Deleted '{$plugin->name}' plugin." ); ++$successes; } else { + WP_CLI::warning( "The '{$plugin->name}' plugin could not be deleted." ); ++$errors; } } @@ -1297,6 +1298,6 @@ private function delete_plugin( $plugin ) { $command = 'rm -rf '; } - return ! WP_CLI::launch( $command . escapeshellarg( $path ) ); + return ! WP_CLI::launch( $command . escapeshellarg( $path ), false ); } }