/
plugin-update.feature
265 lines (220 loc) · 7.51 KB
/
plugin-update.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
Feature: Update WordPress plugins
@require-wp-5.2
Scenario: Updating plugin with invalid version shouldn't remove the old version
Given a WP install
When I run `wp plugin install wordpress-importer --version=0.5 --force`
Then STDOUT should not be empty
When I run `wp plugin list --name=wordpress-importer --field=update_version`
Then STDOUT should not be empty
And save STDOUT as {UPDATE_VERSION}
When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version | update_version | auto_update |
| wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | off |
When I try `wp plugin update akismet --version=0.5.3`
Then STDERR should be:
"""
Error: Can't find the requested plugin's version 0.5.3 in the WordPress.org plugin repository (HTTP code 404).
"""
And the return code should be 1
When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version | update_version | auto_update |
| wordpress-importer | inactive | available | 0.5 | {UPDATE_VERSION} | off |
When I run `wp plugin update wordpress-importer`
Then STDOUT should not be empty
When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version | update_version | auto_update |
| wordpress-importer | inactive | none | {UPDATE_VERSION} | | off |
Scenario: Error when both --minor and --patch are provided
Given a WP install
When I try `wp plugin update --patch --minor --all`
Then STDERR should be:
"""
Error: --minor and --patch cannot be used together.
"""
And the return code should be 1
@require-wp-5.2
Scenario: Exclude plugin updates from bulk updates.
Given a WP install
When I run `wp plugin install wordpress-importer --version=0.5 --force`
Then STDOUT should contain:
"""
Downloading install
"""
And STDOUT should contain:
"""
package from https://downloads.wordpress.org/plugin/wordpress-importer.0.5.zip...
"""
When I run `wp plugin status wordpress-importer`
Then STDOUT should contain:
"""
Update available
"""
When I run `wp plugin update --all --exclude=wordpress-importer | grep 'Skipped'`
Then STDOUT should contain:
"""
wordpress-importer
"""
When I run `wp plugin status wordpress-importer`
Then STDOUT should contain:
"""
Update available
"""
@require-wp-5.2
Scenario: Update a plugin to its latest patch release
Given a WP install
And I run `wp plugin install --force wordpress-importer --version=0.5`
When I run `wp plugin update wordpress-importer --patch`
Then STDOUT should contain:
"""
Success: Updated 1 of 1 plugins.
"""
When I run `wp plugin get wordpress-importer --field=version`
Then STDOUT should be:
"""
0.5.2
"""
@require-wp-4.0
Scenario: Update a plugin to its latest minor release
Given a WP install
And I run `wp plugin install --force akismet --version=2.5.4`
When I run `wp plugin update akismet --minor`
Then STDOUT should contain:
"""
Success: Updated 1 of 1 plugins.
"""
When I run `wp plugin get akismet --field=version`
Then STDOUT should be:
"""
2.6.1
"""
@require-wp-5.2
Scenario: Not giving a slug on update should throw an error unless --all given
Given a WP install
And I run `wp plugin path`
And save STDOUT as {PLUGIN_DIR}
And an empty {PLUGIN_DIR} directory
# No plugins installed. Don't give an error if --all given for BC.
When I run `wp plugin update --all`
Then STDOUT should be:
"""
Success: No plugins installed.
"""
When I run `wp plugin update --version=0.6 --all`
Then STDOUT should be:
"""
Success: No plugins installed.
"""
# One plugin installed.
Given I run `wp plugin install wordpress-importer --version=0.5 --force`
When I try `wp plugin update`
Then the return code should be 1
And STDERR should be:
"""
Error: Please specify one or more plugins, or use --all.
"""
And STDOUT should be empty
When I run `wp plugin update --all`
Then STDOUT should contain:
"""
Success: Updated
"""
When I run the previous command again
Then STDOUT should be:
"""
Success: Plugin already updated.
"""
# Note: if given version then re-installs.
When I run `wp plugin update --version=0.6 --all`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
When I run the previous command again
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
# Two plugins installed.
Given I run `wp plugin install akismet --version=2.5.4`
When I run `wp plugin update --all`
Then STDOUT should contain:
"""
Success: Updated
"""
When I run the previous command again
# BUG: note this message should be plural.
Then STDOUT should be:
"""
Success: Plugin already updated.
"""
# Using version with all rarely makes sense and should probably error and do nothing.
When I try `wp plugin update --version=2.5.4 --all`
Then the return code should be 1
And STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
And STDERR should be:
"""
Error: Can't find the requested plugin's version 2.5.4 in the WordPress.org plugin repository (HTTP code 404).
"""
@require-wp-4.7
Scenario: Plugin updates that error should not report a success
Given a WP install
And I run `wp plugin install --force akismet --version=4.0`
When I run `chmod -w wp-content/plugins/akismet`
And I try `wp plugin update akismet`
Then STDERR should contain:
"""
Error:
"""
Then STDOUT should not contain:
"""
Success:
"""
When I run `chmod +w wp-content/plugins/akismet`
And I try `wp plugin update akismet`
Then STDERR should not contain:
"""
Error:
"""
Then STDOUT should contain:
"""
Success:
"""
Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin update --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
@require-wp-5.2
Scenario: Updating all plugins with some of them having an invalid version shouldn't report an error
Given a WP install
And I run `wp plugin delete akismet`
When I run `wp plugin install health-check --version=1.5.0`
Then STDOUT should not be empty
When I run `wp plugin install wordpress-importer --version=0.5`
Then STDOUT should not be empty
When I run `sed -i.bak 's/Version: .*/Version: 10000/' $(wp plugin path health-check)`
Then STDOUT should be empty
And the return code should be 0
When I try `wp plugin update --all`
Then STDERR should contain:
"""
Warning: health-check: version higher than expected.
"""
And STDOUT should not contain:
"""
Error: Only updated 1 of 1 plugins.
"""
And STDOUT should contain:
"""
Success: Updated 1 of 1 plugins (1 skipped).
"""