-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathplugin-install.feature
More file actions
479 lines (417 loc) · 14.6 KB
/
plugin-install.feature
File metadata and controls
479 lines (417 loc) · 14.6 KB
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
Feature: Install WordPress plugins
Background:
Given an empty cache
Scenario: Branch names should be removed from Github projects
Given a WP install
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/archive/refs/heads/master.zip --activate`
Then STDOUT should contain:
"""
Downloading install
"""
And STDOUT should contain:
"""
package from https://github.com/wp-cli-test/generic-example-plugin/archive/refs/heads/master.zip
"""
And STDOUT should contain:
"""
Renamed Github-based project from 'generic-example-plugin-master' to 'generic-example-plugin'.
"""
And STDOUT should contain:
"""
Plugin installed successfully.
"""
And the wp-content/plugins/generic-example-plugin directory should exist
And the wp-content/plugins/generic-example-plugin-master directory should not exist
When I try `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/archive/refs/heads/master.zip`
Then STDERR should contain:
"""
Warning: Destination folder already exists
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
And the wp-content/plugins/generic-example-plugin directory should exist
And the wp-content/plugins/generic-example-plugin-master directory should not exist
And the return code should be 1
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/archive/refs/heads/master.zip --force`
Then STDOUT should contain:
"""
Plugin updated successfully.
"""
And the wp-content/plugins/generic-example-plugin directory should exist
And the wp-content/plugins/generic-example-plugin-master directory should not exist
# However if the plugin slug ('modern-framework') does not match the project name then it's downloaded to wrong directory.
When I run `wp plugin install https://github.com/Miller-Media/modern-wordpress/archive/master.zip`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should match /Renamed Github-based project from 'modern-(?:wordpress|framework)-master' to 'modern-wordpress'/
# Wrong directory.
And the wp-content/plugins/modern-wordpress directory should exist
And the wp-content/plugins/modern-framework directory should not exist
Scenario: Don't attempt to rename ZIPs uploaded to GitHub's releases page
Given a WP install
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.0/generic-example-plugin.0.1.0.zip`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should not contain:
"""
Renamed Github-based project from 'generic-example-plugin-0.1.0' to 'generic-example-plugin'.
"""
And the wp-content/plugins/generic-example-plugin directory should exist
Scenario: Don't attempt to rename ZIPs coming from a GitHub raw source
Given a WP install
When I run `wp plugin install https://github.com/Miller-Media/modern-wordpress/raw/master/builds/modern-framework-stable.zip`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should not contain:
"""
Renamed Github-based project from 'modern-framework-stable' to 'modern-framework'.
"""
And the wp-content/plugins/modern-framework directory should exist
Scenario: Installing respects WP_PROXY_HOST and WP_PROXY_PORT
Given a WP install
And a invalid-proxy-details.php file:
"""
<?php
define( 'WP_PROXY_HOST', 'https://wp-cli.org' );
define( 'WP_PROXY_PORT', '443' );
"""
When I try `wp --require=invalid-proxy-details.php plugin install debug-bar`
Then STDERR should contain:
"""
Warning: debug-bar: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration.
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
And STDOUT should be empty
And the return code should be 1
When I run `wp plugin install debug-bar`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
Scenario: Return code is 1 when one or more plugin installations fail
Given a WP install
When I try `wp plugin install site-secrets site-secrets-not-a-plugin`
Then STDERR should contain:
"""
Warning:
"""
And STDERR should contain:
"""
site-secrets-not-a-plugin
"""
And STDERR should contain:
"""
Error: Only installed 1 of 2 plugins.
"""
And STDOUT should contain:
"""
Installing Site Secrets
"""
And STDOUT should contain:
"""
Plugin installed successfully.
"""
And the return code should be 1
When I try `wp plugin install site-secrets`
Then STDOUT should be:
"""
Success: Plugin already installed.
"""
And STDERR should be:
"""
Warning: site-secrets: Plugin already installed.
"""
And the return code should be 0
When I try `wp plugin install site-secrets-not-a-plugin`
Then STDERR should contain:
"""
Warning:
"""
And STDERR should contain:
"""
site-secrets-not-a-plugin
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
And the return code should be 1
Scenario: Paths aren't backslashed when destination folder already exists
Given a WP install
When I run `pwd`
Then save STDOUT as {WORKING_DIR}
When I run `rm wp-content/plugins/akismet/akismet.php`
Then the return code should be 0
When I try `wp plugin install akismet --ignore-requirements`
Then STDERR should contain:
"""
Warning: Destination folder already exists. "{WORKING_DIR}/wp-content/plugins/akismet/"
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
And the return code should be 1
Scenario: For Github archive URLs use the Github project name as the plugin directory
Given a WP install
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/archive/v0.1.0.zip`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should contain:
"""
package from https://github.com/wp-cli-test/generic-example-plugin/archive/v0.1.0.zip
"""
And STDOUT should contain:
"""
Renamed Github-based project from 'generic-example-plugin-0.1.0' to 'generic-example-plugin'.
"""
And the wp-content/plugins/generic-example-plugin directory should exist
And the wp-content/plugins/generic-example-plugi directory should not exist
And the wp-content/plugins/generic-example-plugin-0.1.0 directory should not exist
When I run `wp plugin install https://github.com/Automattic/sensei/archive/version/1.9.19.zip`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should contain:
"""
package from https://github.com/Automattic/sensei/archive/version/1.9.19.zip
"""
And STDOUT should contain:
"""
Renamed Github-based project from 'sensei-version-1.9.19' to 'sensei'.
"""
And the wp-content/plugins/sensei directory should exist
And the wp-content/plugins/archive directory should not exist
And the wp-content/plugins/sensei-version-1.9.19 directory should not exist
Scenario: Verify installed plugin activation
Given a WP install
When I run `wp plugin install site-secrets`
Then STDOUT should not be empty
When I try `wp plugin install site-secrets --activate`
Then STDERR should contain:
"""
Warning: site-secrets: Plugin already installed.
"""
And STDOUT should contain:
"""
Activating 'site-secrets'...
Plugin 'site-secrets' activated.
Success: Plugin already installed.
"""
@require-php-7
Scenario: Can't install plugin that requires a newer version of WordPress
Given a WP install
When I run `wp core download --version=6.4 --force`
And I run `rm -r wp-content/themes/*`
And I try `wp plugin install wp-super-cache`
Then STDERR should contain:
"""
Warning: wp-super-cache: This plugin does not work with your version of WordPress
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
@less-than-php-7.4 @require-wp-6.6
Scenario: Can't install plugin that requires a newer version of PHP
Given a WP install
And I try `wp plugin install contact-form-7`
Then STDERR should contain:
"""
Warning: contact-form-7: This plugin does not work with your version of PHP
"""
And STDERR should contain:
"""
Error: No plugins installed.
"""
Scenario: Install plugin from a single PHP file URL
Given a WP install
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --activate`
Then STDOUT should contain:
"""
Installing
"""
And STDOUT should contain:
"""
Downloading plugin file from
"""
And STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should contain:
"""
Activating
"""
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
When I run `wp plugin list --field=name`
Then STDOUT should contain:
"""
pwa-manifest-short-name
"""
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
Then STDOUT should be:
"""
active
"""
Scenario: Install plugin from a single PHP file URL with --force flag
Given a WP install
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
When I try `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
Then STDERR should contain:
"""
Warning: Plugin already installed.
"""
And STDERR should not contain:
"""
plugin could not be found
"""
And STDOUT should contain:
"""
Success: Plugin already installed.
"""
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --force`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
@github-api
Scenario: Install plugin from a GitHub Gist page URL
Given a WP install
When I run `wp plugin install https://gist.github.com/westonruter/dec7d190060732e29a09751ab99cc549 --activate`
Then STDOUT should contain:
"""
Gist resolved to raw file URL.
"""
And STDOUT should contain:
"""
Installing
"""
And STDOUT should contain:
"""
Downloading plugin file from
"""
And STDOUT should contain:
"""
Plugin installed successfully.
"""
And STDOUT should contain:
"""
Activating
"""
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
Then STDOUT should be:
"""
active
"""
Scenario: Install plugin using WordPress.org directory URL
Given a WP install
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/`
Then STDOUT should contain:
"""
Detected WordPress.org plugins directory URL, using slug: debug-bar
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
inactive
"""
Scenario: Install and activate plugin using WordPress.org directory URL
Given a WP install
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/ --activate`
Then STDOUT should contain:
"""
Detected WordPress.org plugins directory URL, using slug: debug-bar
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
"""
Scenario: Install with --activate on already-active plugin should keep it activated
Given a WP install
When I run `wp plugin install debug-bar --activate`
Then STDOUT should contain:
"""
Plugin 'debug-bar' activated.
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
"""
When I try `wp plugin install debug-bar --activate`
Then STDERR should contain:
"""
Warning: debug-bar: Plugin already installed.
"""
And STDOUT should contain:
"""
Activating 'debug-bar'...
"""
And STDOUT should contain:
"""
Plugin 'debug-bar' activated.
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
"""
Scenario: Install with --activate-network on already-network-active plugin should keep it activated
Given a WP multisite install
When I run `wp plugin install debug-bar --activate-network`
Then STDOUT should contain:
"""
Plugin 'debug-bar' network activated.
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active-network
"""
When I try `wp plugin install debug-bar --activate-network`
Then STDERR should contain:
"""
Warning: debug-bar: Plugin already installed.
"""
And STDOUT should contain:
"""
Network-activating 'debug-bar'...
"""
And STDOUT should contain:
"""
Plugin 'debug-bar' network activated.
"""
And the return code should be 0
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active-network
"""