Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
features: Add more tests for uninstall
  • Loading branch information
dkoston committed Dec 10, 2024
commit ec280cb727ab14e0c774788e6f8ee408cee3cd59
57 changes: 57 additions & 0 deletions features/plugin-uninstall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,40 @@ Feature: Uninstall a WordPress plugin
Success: Uninstalled 1 of 1 plugins.
"""
And the return code should be 0
And STDERR should be empty
And the wp-content/plugins/akismet directory should not exist


Scenario: Uninstall an installed plugin but do not delete its files
When I run `wp plugin uninstall akismet --skip-delete`
Then STDOUT should be:
"""
Ran uninstall procedure for 'akismet' plugin without deleting.
Success: Uninstalled 1 of 1 plugins.
"""
And the return code should be 0
And STDERR should be empty
And the wp-content/plugins/akismet directory should exist

Scenario: Uninstall a plugin that is not in a folder and has custom name
When I run `wp plugin uninstall hello`
Then STDOUT should be:
"""
Uninstalled and deleted 'hello' plugin.
Success: Uninstalled 1 of 1 plugins.
"""
And the return code should be 0
And STDERR should be empty
And the wp-content/plugins/hello.php file should not exist

Scenario: Missing required inputs
When I run `wp plugin uninstall`
Then STDERR should be:
"""
Error: Please specify one or more plugins, or use --all.
"""
And the return code should be 1
And STDOUT should be empty

Scenario: Attempting to uninstall a plugin that's activated
When I run `wp plugin activate akismet`
Expand All @@ -25,6 +59,21 @@ Feature: Uninstall a WordPress plugin
And STDOUT should be empty
And the return code should be 1

Scenario: Attempting to uninstall a plugin that's activated (using --deactivate)
When I run `wp plugin activate akismet`
Then STDOUT should not be empty

When I try `wp plugin uninstall akismet --deactivate`
Then STDOUT should be:
"""
Deactivating 'akismet'...
Plugin 'akismet' deactivated.
Uninstalled and deleted 'akismet' plugin.
Success: Uninstalled 1 of 1 plugins.
"""
And STDERR should be empty
And the return code should be 0

Scenario: Attempting to uninstall a plugin that doesn't exist
When I try `wp plugin uninstall debug-bar`
Then STDERR should be:
Expand All @@ -43,12 +92,14 @@ Feature: Uninstall a WordPress plugin
Success: Uninstalled 2 of 2 plugins.
"""
And the return code should be 0
And STDERR should be empty

When I run the previous command again
Then STDOUT should be:
"""
Success: No plugins uninstalled.
"""
And STDERR should be empty

Scenario: Uninstall all installed plugins when one or more activated
When I run `wp plugin activate --all`
Expand All @@ -65,12 +116,14 @@ Feature: Uninstall a WordPress plugin
Error: No plugins uninstalled.
"""
And the return code should be 1
And STDOUT should be empty

When I run `wp plugin uninstall --deactivate --all`
Then STDOUT should contain:
"""
Success: Uninstalled 2 of 2 plugins.
"""
And STDERR should be empty

Scenario: Excluding a plugin from uninstallation when using --all switch
When I try `wp plugin uninstall --all --exclude=akismet,hello`
Expand All @@ -79,6 +132,7 @@ Feature: Uninstall a WordPress plugin
Success: No plugins uninstalled.
"""
And the return code should be 0
And STDERR should be empty

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
Expand All @@ -104,6 +158,7 @@ Feature: Uninstall a WordPress plugin
"""
And the wp-content/languages/plugins/wordpress-importer-fr_FR.mo file should exist
And the wp-content/languages/plugins/wordpress-importer-fr_FR.po file should exist
And the wp-content/languages/plugins/wordpress-importer-fr_FR.l10n.php file should exist

When I run `wp plugin uninstall wordpress-importer`
Then STDOUT should contain:
Expand All @@ -112,3 +167,5 @@ Feature: Uninstall a WordPress plugin
"""
And the wp-content/languages/plugins/wordpress-importer-fr_FR.mo file should not exist
And the wp-content/languages/plugins/wordpress-importer-fr_FR.po file should not exist
And the wp-content/languages/plugins/wordpress-importer-fr_FR.l10n.php file should not exist
And STDERR should be empty
2 changes: 1 addition & 1 deletion src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ public function uninstall( $args, $assoc_args = array() ) {
WP_CLI::log( "Uninstalled and deleted '$plugin->name' plugin." );
} else {
$delete_errors[] = $plugin->file;
WP_CLI::log( "Ran uninstall procedure for '$plugin->name' plugin. Deletion failed" );
WP_CLI::log( "Ran uninstall procedure for '$plugin->name' plugin. Deletion of plugin files failed" );
++$errors;
continue;
}
Expand Down
Loading