Skip to content

Commit ec280cb

Browse files
committed
features: Add more tests for uninstall
1 parent 60d9786 commit ec280cb

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

features/plugin-uninstall.feature

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,40 @@ Feature: Uninstall a WordPress plugin
1111
Success: Uninstalled 1 of 1 plugins.
1212
"""
1313
And the return code should be 0
14+
And STDERR should be empty
15+
And the wp-content/plugins/akismet directory should not exist
16+
17+
18+
Scenario: Uninstall an installed plugin but do not delete its files
19+
When I run `wp plugin uninstall akismet --skip-delete`
20+
Then STDOUT should be:
21+
"""
22+
Ran uninstall procedure for 'akismet' plugin without deleting.
23+
Success: Uninstalled 1 of 1 plugins.
24+
"""
25+
And the return code should be 0
26+
And STDERR should be empty
27+
And the wp-content/plugins/akismet directory should exist
28+
29+
Scenario: Uninstall a plugin that is not in a folder and has custom name
30+
When I run `wp plugin uninstall hello`
31+
Then STDOUT should be:
32+
"""
33+
Uninstalled and deleted 'hello' plugin.
34+
Success: Uninstalled 1 of 1 plugins.
35+
"""
36+
And the return code should be 0
37+
And STDERR should be empty
38+
And the wp-content/plugins/hello.php file should not exist
39+
40+
Scenario: Missing required inputs
41+
When I run `wp plugin uninstall`
42+
Then STDERR should be:
43+
"""
44+
Error: Please specify one or more plugins, or use --all.
45+
"""
46+
And the return code should be 1
47+
And STDOUT should be empty
1448

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

62+
Scenario: Attempting to uninstall a plugin that's activated (using --deactivate)
63+
When I run `wp plugin activate akismet`
64+
Then STDOUT should not be empty
65+
66+
When I try `wp plugin uninstall akismet --deactivate`
67+
Then STDOUT should be:
68+
"""
69+
Deactivating 'akismet'...
70+
Plugin 'akismet' deactivated.
71+
Uninstalled and deleted 'akismet' plugin.
72+
Success: Uninstalled 1 of 1 plugins.
73+
"""
74+
And STDERR should be empty
75+
And the return code should be 0
76+
2877
Scenario: Attempting to uninstall a plugin that doesn't exist
2978
When I try `wp plugin uninstall debug-bar`
3079
Then STDERR should be:
@@ -43,12 +92,14 @@ Feature: Uninstall a WordPress plugin
4392
Success: Uninstalled 2 of 2 plugins.
4493
"""
4594
And the return code should be 0
95+
And STDERR should be empty
4696

4797
When I run the previous command again
4898
Then STDOUT should be:
4999
"""
50100
Success: No plugins uninstalled.
51101
"""
102+
And STDERR should be empty
52103

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

69121
When I run `wp plugin uninstall --deactivate --all`
70122
Then STDOUT should contain:
71123
"""
72124
Success: Uninstalled 2 of 2 plugins.
73125
"""
126+
And STDERR should be empty
74127

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

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

108163
When I run `wp plugin uninstall wordpress-importer`
109164
Then STDOUT should contain:
@@ -112,3 +167,5 @@ Feature: Uninstall a WordPress plugin
112167
"""
113168
And the wp-content/languages/plugins/wordpress-importer-fr_FR.mo file should not exist
114169
And the wp-content/languages/plugins/wordpress-importer-fr_FR.po file should not exist
170+
And the wp-content/languages/plugins/wordpress-importer-fr_FR.l10n.php file should not exist
171+
And STDERR should be empty

src/Plugin_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ public function uninstall( $args, $assoc_args = array() ) {
11581158
WP_CLI::log( "Uninstalled and deleted '$plugin->name' plugin." );
11591159
} else {
11601160
$delete_errors[] = $plugin->file;
1161-
WP_CLI::log( "Ran uninstall procedure for '$plugin->name' plugin. Deletion failed" );
1161+
WP_CLI::log( "Ran uninstall procedure for '$plugin->name' plugin. Deletion of plugin files failed" );
11621162
++$errors;
11631163
continue;
11641164
}

0 commit comments

Comments
 (0)