-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathcore-update.feature
More file actions
626 lines (545 loc) · 18.8 KB
/
core-update.feature
File metadata and controls
626 lines (545 loc) · 18.8 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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
Feature: Update WordPress core
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Update from a ZIP file
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core download --version=6.2 --force`
Then STDOUT should not be empty
When I try `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
6.2
"""
When I run `wget http://wordpress.org/wordpress-6.2.zip --quiet`
And I run `wp core update wordpress-6.2.zip`
Then STDOUT should be:
"""
Starting update...
Unpacking the update...
Cleaning up files...
No old files were removed.
Success: WordPress updated successfully.
"""
When I try `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
6.2
"""
@require-php-7.0
Scenario: Output in JSON format
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core download --version=6.6 --force`
Then STDOUT should not be empty
When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
6.6
"""
When I run `wget http://wordpress.org/wordpress-6.8.zip --quiet`
And I run `wp core update wordpress-6.8.zip --format=json`
Then STDOUT should be:
"""
[{"name":"core","old_version":"6.6","new_version":"6.8","status":"Updated"}]
"""
@require-php-7.0
Scenario: Output in CSV format
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core download --version=6.6 --force`
Then STDOUT should not be empty
When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
6.6
"""
When I run `wget http://wordpress.org/wordpress-6.8.zip --quiet`
And I run `wp core update wordpress-6.8.zip --format=csv`
Then STDOUT should be:
"""
name,old_version,new_version,status
core,6.6,6.8,Updated
"""
@require-php-7.0
Scenario: Output in table format
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core download --version=6.6 --force`
Then STDOUT should not be empty
When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
6.6
"""
When I run `wget http://wordpress.org/wordpress-6.8.zip --quiet`
And I run `wp core update wordpress-6.8.zip --format=table`
Then STDOUT should end with a table containing rows:
| name | old_version | new_version | status |
| core | 6.6 | 6.8 | Updated |
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Update to the latest minor release (PHP 7.2 compatible with WP >= 4.9)
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core download --version=6.2.5 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""
# This version of WP throws a PHP notice
When I try `wp core update --minor`
Then STDOUT should contain:
"""
Updating to version {WP_VERSION-6.2-latest}
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
And the return code should be 0
When I run `wp core update --minor`
Then STDOUT should be:
"""
Success: WordPress is at the latest minor release.
"""
When I run `wp core version`
Then STDOUT should be:
"""
{WP_VERSION-6.2-latest}
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Core update from cache
Given a WP install
And I try `wp theme install twentytwenty --activate`
And an empty cache
When I run `wp core update --version=6.2.5 --force`
Then STDOUT should not contain:
"""
Using cached file
"""
And STDOUT should contain:
"""
Downloading
"""
When I run `wp core update --version=6.0 --force`
Then STDOUT should not be empty
When I run `wp core update --version=6.2.5 --force`
Then STDOUT should contain:
"""
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-6.2.5-en_US.zip'...
"""
And STDOUT should not contain:
"""
Downloading
"""
@require-php-7.0
Scenario: Don't run update when up-to-date
Given a WP install
And I run `wp core update`
When I run `wp core update`
Then STDOUT should contain:
"""
WordPress is up to date at version
"""
And STDOUT should not contain:
"""
Updating
"""
When I run `wp core update --force`
Then STDOUT should contain:
"""
Updating
"""
Scenario: Ensure cached partial upgrades aren't used in full upgrade
Given a WP install
And I try `wp theme install twentytwenty --activate`
And an empty cache
And a wp-content/mu-plugins/upgrade-override.php file:
"""
<?php
add_filter( 'pre_site_transient_update_core', function(){
return (object) array(
'updates' => array(
(object) array(
'response' => 'autoupdate',
'download' => 'https://downloads.wordpress.org/release/wordpress-6.5.5.zip',
'locale' => 'en_US',
'packages' => (object) array(
'full' => 'https://downloads.wordpress.org/release/wordpress-6.5.5.zip',
'no_content' => 'https://downloads.wordpress.org/release/wordpress-6.5.5-no-content.zip',
'new_bundled' => 'https://downloads.wordpress.org/release/wordpress-6.5.5-new-bundled.zip',
'partial' => 'https://downloads.wordpress.org/release/wordpress-6.5.5-partial-1.zip',
'rollback' => 'https://downloads.wordpress.org/release/wordpress-6.5.5-rollback-1.zip',
),
'current' => '6.5.5',
'version' => '6.5.5',
'php_version' => '8.2.1',
'mysql_version' => '5.0',
'new_bundled' => '6.4',
'partial_version' => '6.5.2',
'support_email' => 'updatehelp42@wordpress.org',
'new_files' => '',
),
),
'version_checked' => '6.5.5', // Needed to avoid PHP notice in `wp_version_check()`.
);
});
"""
When I run `wp core download --version=6.5.2 --force`
And I run `wp core update`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
And the {SUITE_CACHE_DIR}/core directory should contain:
"""
wordpress-6.5.2-en_US.tar.gz
wordpress-6.5.5-partial-1-en_US.zip
"""
# Allow for implicit nullable warnings produced by Requests.
When I try `wp core download --version=6.4.1 --force`
And I run `wp core update`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
# Allow for warnings to be produced.
When I try `wp core verify-checksums`
Then STDOUT should be:
"""
Success: WordPress installation verifies against checksums.
"""
And the {SUITE_CACHE_DIR}/core directory should contain:
"""
wordpress-6.4.1-en_US.tar.gz
wordpress-6.5.2-en_US.tar.gz
wordpress-6.5.5-no-content-en_US.zip
wordpress-6.5.5-partial-1-en_US.zip
"""
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
@less-than-php-7.3 @require-mysql
Scenario: Make sure files are cleaned up
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core update --version=4.4 --force`
Then the wp-includes/rest-api.php file should exist
And the wp-includes/class-wp-comment.php file should exist
And STDOUT should not contain:
"""
File removed: wp-content
"""
When I run `wp core update --version=4.3.2 --force`
Then the wp-includes/rest-api.php file should not exist
And the wp-includes/class-wp-comment.php file should not exist
And STDOUT should contain:
"""
File removed: wp-includes/class-walker-comment.php
File removed: wp-includes/class-wp-network.php
File removed: wp-includes/embed-template.php
File removed: wp-includes/class-wp-comment.php
File removed: wp-includes/class-wp-http-response.php
File removed: wp-includes/class-walker-category-dropdown.php
File removed: wp-includes/rest-api.php
"""
And STDOUT should not contain:
"""
File removed: wp-content
"""
When I run `wp option add str_opt 'bar'`
Then STDOUT should not be empty
When I run `wp post create --post_title='Test post' --porcelain`
Then STDOUT should be a number
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.4+
@require-mysql
Scenario: Make sure files are cleaned up with mixed case
Given a WP install
And I try `wp theme install twentytwenty --activate`
When I run `wp core update --version=5.8 --force`
Then the wp-includes/Requests/Transport/cURL.php file should exist
And the wp-includes/Requests/Exception/Transport/cURL.php file should exist
And the wp-includes/Requests/Exception/HTTP/502.php file should exist
And the wp-includes/Requests/IRI.php file should exist
And the wp-includes/Requests/src/Transport/Curl.php file should not exist
And the wp-includes/Requests/src/Exception/Transport/Curl.php file should not exist
And the wp-includes/Requests/src/Exception/Http/Status502.php file should not exist
And the wp-includes/Requests/src/Iri.php file should not exist
And STDOUT should contain:
"""
Cleaning up files...
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
When I run `wp core update --version=6.2 --force`
Then the wp-includes/Requests/Transport/cURL.php file should not exist
And the wp-includes/Requests/Exception/Transport/cURL.php file should not exist
And the wp-includes/Requests/Exception/HTTP/502.php file should not exist
And the wp-includes/Requests/IRI.php file should not exist
And the wp-includes/Requests/src/Transport/Curl.php file should exist
And the wp-includes/Requests/src/Exception/Transport/Curl.php file should exist
And the wp-includes/Requests/src/Exception/Http/Status502.php file should exist
And the wp-includes/Requests/src/Iri.php file should exist
And STDOUT should contain:
"""
Cleaning up files...
"""
When I run `wp option add str_opt 'bar'`
Then STDOUT should not be empty
When I run `wp post create --post_title='Test post' --porcelain`
Then STDOUT should be a number
@require-php-7.4
Scenario Outline: Use `--version=(nightly|trunk)` to update to the latest nightly version
Given a WP install
When I run `wp core update --version=<version>`
Then STDOUT should contain:
"""
Updating to version nightly (en_US)...
Downloading update from https://wordpress.org/nightly-builds/wordpress-latest.zip...
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
Examples:
| version |
| trunk |
| nightly |
@require-php-7.4
Scenario: Installing latest nightly build should skip cache
Given a WP install
# May produce warnings if checksums cannot be retrieved.
When I try `wp core upgrade --force http://wordpress.org/nightly-builds/wordpress-latest.zip`
Then STDOUT should contain:
"""
Success:
"""
And STDOUT should not contain:
"""
Using cached
"""
# May produce warnings if checksums cannot be retrieved.
When I try `wp core upgrade --force http://wordpress.org/nightly-builds/wordpress-latest.zip`
Then STDOUT should contain:
"""
Success:
"""
And STDOUT should not contain:
"""
Using cached
"""
Scenario: Allow installing major version with trailing zero
Given a WP install
When I run `wp core update --version=6.2.0 --force`
Then STDOUT should contain:
"""
Success:
"""
Scenario: No HTML output from async translation updates during core update
Given a WP install
And an empty cache
# Using `try` in case there are checksum warnings.
When I try `wp core download --version=6.5 --locale=de_DE --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""
When I run `wp core version --extra`
Then STDOUT should contain:
"""
Package language: de_DE
"""
When I run `wp core update --version=latest --force`
Then STDOUT should not contain:
"""
<p>
"""
And STDOUT should not contain:
"""
<div
"""
And STDOUT should not contain:
"""
<script
"""
And STDOUT should not contain:
"""
</div>
"""
Scenario: Old files from $_old_files are cleaned up when upgrading
Given a WP install
When I run `wp core download --version=6.8 --force`
# Create files that should be removed according to 6.9 old_files list
Given a wp-includes/blocks/post-author/editor.css file:
"""
/* Old CSS file */
"""
And a wp-includes/blocks/post-author/editor.min.css file:
"""
/* Old minified CSS */
"""
And a wp-includes/blocks/post-author/editor-rtl.css file:
"""
/* Old RTL CSS */
"""
And a wp-includes/blocks/post-author/editor-rtl.min.css file:
"""
/* Old RTL minified CSS */
"""
And a wp-includes/SimplePie/src/Core.php file:
"""
<?php
// Old SimplePie Core file
"""
And an empty wp-includes/SimplePie/src/Decode directory
When I run `wp core update --version=6.9 --force`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
And the wp-includes/blocks/post-author/editor.css file should not exist
And the wp-includes/blocks/post-author/editor.min.css file should not exist
And the wp-includes/blocks/post-author/editor-rtl.css file should not exist
And the wp-includes/blocks/post-author/editor-rtl.min.css file should not exist
And the wp-includes/SimplePie/src/Core.php file should not exist
And the wp-includes/SimplePie/src/Decode directory should not exist
@require-php-7.2
Scenario: Old files cleanup works when checksums unavailable
Given a WP install
When I run `wp core download --version=6.8 --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""
# Create files that exist in the $_old_files list from WordPress 6.9
Given a wp-includes/blocks/post-author/editor.css file:
"""
/* Old CSS file */
"""
And a wp-includes/blocks/post-author/editor.min.css file:
"""
/* Old minified CSS */
"""
# Mock checksum API to return empty response so checksums are unavailable
And that HTTP requests to https://api.wordpress.org/core/checksums/1.0/ will respond with:
"""
HTTP/1.1 200
Content-Type: application/json
{}
"""
When I try `wp core update --version=6.9 --force`
Then STDOUT should contain:
"""
Cleaning up files...
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
# Verify files from $_old_files were removed
And the wp-includes/blocks/post-author/editor.css file should not exist
And the wp-includes/blocks/post-author/editor.min.css file should not exist
Scenario: Update WordPress locale without --force when version is the same
Given a WP install
And an empty cache
# Using `try` in case there are checksum warnings.
When I try `wp core download --version=6.5 --locale=de_DE --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""
When I run `wp core version --extra`
Then STDOUT should contain:
"""
Package language: de_DE
"""
When I run `wp core version`
Then save STDOUT as {CURRENT_VERSION}
# Updating to the same version with a different locale should work without --force.
When I run `wp core update --version={CURRENT_VERSION} --locale=en_US`
Then STDOUT should contain:
"""
Updating to version {CURRENT_VERSION} (en_US)...
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
When I run `wp core version --extra`
Then STDOUT should contain:
"""
Package language: en_US
"""
Scenario: Update WordPress locale when using --minor
Given a WP install
And an empty cache
# Using `try` in case there are checksum warnings.
When I try `wp core download --version=6.5 --locale=de_DE --force`
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""
When I run `wp core version --extra`
Then STDOUT should contain:
"""
Package language: de_DE
"""
When I run `wp core update --minor --locale=en_US`
Then STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
When I run `wp core version --extra`
Then STDOUT should contain:
"""
Package language: en_US
"""
@require-wp-6.1
Scenario: Attempting to downgrade without --force shows helpful message
Given a WP install
When I run `wp core version`
Then save STDOUT as {WP_CURRENT_VERSION}
When I try `wp core update --version=6.0`
Then STDOUT should contain:
"""
WordPress is up to date at version
"""
And STDOUT should contain:
"""
is older than the current version
"""
And STDOUT should contain:
"""
Use --force to update anyway
"""
And STDOUT should not contain:
"""
Success:
"""
And the return code should be 0
When I run `wp core update --version=6.0 --force`
Then STDOUT should contain:
"""
Updating to version 6.0
"""
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""
Scenario: Show helpful tip when update is locked
Given a WP install
When I run `wp option update core_updater.lock 100000000000000`
And I try `wp core update --version=trunk`
Then STDERR should contain:
"""
Another update is currently in progress. You may need to run `wp option delete core_updater.lock` after verifying another update isn't actually running.
"""
And the return code should be 1
# Clean up the lock
When I run `wp option delete core_updater.lock`
Then STDOUT should contain:
"""
Success:
"""