-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathcore-update.feature
More file actions
411 lines (358 loc) · 12.9 KB
/
core-update.feature
File metadata and controls
411 lines (358 loc) · 12.9 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
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...
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
"""
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.2
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.2
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: Show helpful tip when update is locked
Given a WP install
# Create a lock option to simulate another update in progress
When I run `wp option add core_updater.lock 1`
Then STDOUT should contain:
"""
Success:
"""
# Try to update and expect the lock error with helpful tip
When I try `wp core update --version=latest`
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:
"""