Skip to content

Commit f30182b

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

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

features/plugin-uninstall.feature

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ 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 STDOUT should be:
43+
"""
44+
Please specify one or more plugins, or use --all.
45+
"""
46+
And the return code should be 1
1447

1548
Scenario: Attempting to uninstall a plugin that's activated
1649
When I run `wp plugin activate akismet`
@@ -25,6 +58,19 @@ Feature: Uninstall a WordPress plugin
2558
And STDOUT should be empty
2659
And the return code should be 1
2760

61+
Scenario: Attempting to uninstall a plugin that's activated (using --deactivate)
62+
When I run `wp plugin activate akismet`
63+
Then STDOUT should not be empty
64+
65+
When I try `wp plugin uninstall akismet --deactivate`
66+
Then STDOUT should be:
67+
"""
68+
Uninstalled and deleted 'akismet' plugin.
69+
Success: Uninstalled 1 of 1 plugins.
70+
"""
71+
And STDERR should be empty
72+
And the return code should be 0
73+
2874
Scenario: Attempting to uninstall a plugin that doesn't exist
2975
When I try `wp plugin uninstall debug-bar`
3076
Then STDERR should be:
@@ -43,12 +89,14 @@ Feature: Uninstall a WordPress plugin
4389
Success: Uninstalled 2 of 2 plugins.
4490
"""
4591
And the return code should be 0
92+
And STDERR should be empty
4693

4794
When I run the previous command again
4895
Then STDOUT should be:
4996
"""
5097
Success: No plugins uninstalled.
5198
"""
99+
And STDERR should be empty
52100

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

69118
When I run `wp plugin uninstall --deactivate --all`
70119
Then STDOUT should contain:
71120
"""
72121
Success: Uninstalled 2 of 2 plugins.
73122
"""
123+
And STDERR should be empty
74124

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

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

108160
When I run `wp plugin uninstall wordpress-importer`
109161
Then STDOUT should contain:
@@ -112,3 +164,5 @@ Feature: Uninstall a WordPress plugin
112164
"""
113165
And the wp-content/languages/plugins/wordpress-importer-fr_FR.mo file should not exist
114166
And the wp-content/languages/plugins/wordpress-importer-fr_FR.po file should not exist
167+
And the wp-content/languages/plugins/wordpress-importer-fr_FR.l10n.php file should not exist
168+
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)