Skip to content

Commit 65478a3

Browse files
committed
Merge branch 'main' into 129-format-core-update
2 parents 40be726 + cd8cb68 commit 65478a3

12 files changed

Lines changed: 414 additions & 353 deletions

.github/workflows/testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Testing
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
push:
67
branches:

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,10 @@ update isn't actually running.
381381
No files found that need cleaning up
382382
Success: WordPress updated successfully.
383383

384-
# Update WordPress to latest version of 3.8 release
385-
$ wp core update --version=3.8 ../latest.zip
386-
Updating to version 3.8 ()...
384+
# Update WordPress using zip file.
385+
$ wp core update ../latest.zip
386+
Starting update...
387387
Unpacking the update...
388-
Cleaning up files...
389-
File removed: wp-admin/js/tags-box.js
390-
...
391-
File removed: wp-admin/js/updates.min.
392-
377 files cleaned up
393388
Success: WordPress updated successfully.
394389

395390
# Update WordPress to 3.1 forcefully

composer.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@
1313
],
1414
"require": {
1515
"composer/semver": "^1.4 || ^2 || ^3",
16-
"wp-cli/wp-cli": "^2.5.1"
16+
"wp-cli/wp-cli": "^2.12"
1717
},
1818
"require-dev": {
1919
"wp-cli/checksum-command": "^1 || ^2",
2020
"wp-cli/db-command": "^1.3 || ^2",
2121
"wp-cli/entity-command": "^1.3 || ^2",
2222
"wp-cli/extension-command": "^1.2 || ^2",
23-
"wp-cli/wp-cli-tests": "^4"
23+
"wp-cli/wp-cli-tests": "^5"
2424
},
2525
"config": {
2626
"process-timeout": 7200,
2727
"sort-packages": true,
2828
"allow-plugins": {
2929
"dealerdirect/phpcodesniffer-composer-installer": true,
30-
"johnpbloch/wordpress-core-installer": true
31-
}
30+
"johnpbloch/wordpress-core-installer": true,
31+
"phpstan/extension-installer": true
32+
},
33+
"lock": false
3234
},
3335
"extra": {
3436
"branch-alias": {
@@ -63,12 +65,14 @@
6365
"behat-rerun": "rerun-behat-tests",
6466
"lint": "run-linter-tests",
6567
"phpcs": "run-phpcs-tests",
68+
"phpstan": "run-phpstan-tests",
6669
"phpcbf": "run-phpcbf-cleanup",
6770
"phpunit": "run-php-unit-tests",
6871
"prepare-tests": "install-package-tests",
6972
"test": [
7073
"@lint",
7174
"@phpcs",
75+
"@phstan",
7276
"@phpunit",
7377
"@behat"
7478
]

features/core-check-update.feature

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,64 @@ Feature: Check for more recent versions
99
When I run `wp core download --version=5.8 --force`
1010
Then STDOUT should not be empty
1111

12-
When I run `wp core check-update`
13-
Then STDOUT should be a table containing rows:
14-
| version | update_type | package_url |
15-
| {WP_VERSION-latest} | major | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-latest}.zip |
16-
| {WP_VERSION-5.8-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip |
12+
When I run `wp core check-update --format=csv`
13+
Then STDOUT should match #{WP_VERSION-latest},major,https://downloads.(w|wordpress).org/release/wordpress-{WP_VERSION-latest}.zip#
14+
And STDOUT should match #{WP_VERSION-5.8-latest},minor,https://downloads.(w|wordpress).org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip#
1715

1816
When I run `wp core check-update --format=count`
1917
Then STDOUT should be:
2018
"""
2119
2
2220
"""
2321

24-
When I run `wp core check-update --major`
25-
Then STDOUT should be a table containing rows:
26-
| version | update_type | package_url |
27-
| {WP_VERSION-latest} | major | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-latest}.zip |
22+
When I run `wp core check-update --major --format=csv`
23+
Then STDOUT should match #{WP_VERSION-latest},major,https://downloads.(w|wordpress).org/release/wordpress-{WP_VERSION-latest}.zip#
2824

2925
When I run `wp core check-update --major --format=count`
3026
Then STDOUT should be:
3127
"""
3228
1
3329
"""
3430

35-
When I run `wp core check-update --minor`
36-
Then STDOUT should be a table containing rows:
37-
| version | update_type | package_url |
38-
| {WP_VERSION-5.8-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip |
31+
When I run `wp core check-update --minor --format=csv`
32+
Then STDOUT should match #{WP_VERSION-5.8-latest},minor,https://downloads.(w|wordpress).org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip#
3933

4034
When I run `wp core check-update --minor --format=count`
4135
Then STDOUT should be:
4236
"""
4337
1
4438
"""
39+
40+
Scenario: Check output of check update in different formats (no updates available)
41+
Given a WP install
42+
And a setup.php file:
43+
"""
44+
<?php
45+
global $wp_version;
46+
47+
$obj = new stdClass;
48+
$obj->updates = [];
49+
$obj->last_checked = strtotime( '1 January 2099' );
50+
$obj->version_checked = $wp_version;
51+
$obj->translations = [];
52+
set_site_transient( 'update_core', $obj );
53+
"""
54+
And I run `wp eval-file setup.php`
55+
56+
When I run `wp core check-update`
57+
Then STDOUT should be:
58+
"""
59+
Success: WordPress is at the latest version.
60+
"""
61+
62+
When I run `wp core check-update --format=json`
63+
Then STDOUT should be:
64+
"""
65+
[]
66+
"""
67+
68+
When I run `wp core check-update --format=yaml`
69+
Then STDOUT should be:
70+
"""
71+
---
72+
"""

features/core-download.feature

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ Feature: Download WordPress
3939
When I run `wp core download --force`
4040
Then the wp-settings.php file should exist
4141
And STDOUT should contain:
42-
"""
43-
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-{VERSION}-en_US.tar.gz'...
44-
"""
42+
"""
43+
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-{VERSION}-en_US.tar.gz'...
44+
"""
4545

4646
Scenario: Localized install
4747
Given an empty directory
@@ -54,7 +54,7 @@ Feature: Download WordPress
5454
Scenario: Catch download of non-existent WP version
5555
Given an empty directory
5656

57-
When I try `wp core download --version=4.1.0 --force`
57+
When I try `wp core download --version=1.0.3 --force`
5858
Then STDERR should contain:
5959
"""
6060
Error: Release not found.
@@ -115,17 +115,18 @@ Feature: Download WordPress
115115

116116
Scenario: Make sure files are cleaned up
117117
Given an empty directory
118+
118119
When I run `wp core download --version=4.4`
119120
Then the wp-includes/rest-api.php file should exist
120-
Then the wp-includes/class-wp-comment.php file should exist
121+
And the wp-includes/class-wp-comment.php file should exist
121122
And STDERR should not contain:
122123
"""
123124
Warning: Failed to find WordPress version. Please cleanup files manually.
124125
"""
125126

126127
When I run `wp core download --version=4.3.2 --force`
127128
Then the wp-includes/rest-api.php file should not exist
128-
Then the wp-includes/class-wp-comment.php file should not exist
129+
And the wp-includes/class-wp-comment.php file should not exist
129130
And STDOUT should not contain:
130131
"""
131132
File removed: wp-content
@@ -238,9 +239,9 @@ Feature: Download WordPress
238239
When I try `wp core download --version=nightly --locale=de_DE`
239240
Then the return code should be 1
240241
And STDERR should contain:
241-
"""
242-
Error: Nightly builds are only available for the en_US locale.
243-
"""
242+
"""
243+
Error: Nightly builds are only available for the en_US locale.
244+
"""
244245

245246
Scenario: Installing a release candidate or beta version
246247
Given an empty directory
@@ -249,7 +250,7 @@ Feature: Download WordPress
249250
# Test with incorrect case.
250251
When I try `wp core download --version=4.6-rc2`
251252
Then the return code should be 1
252-
Then STDERR should contain:
253+
And STDERR should contain:
253254
"""
254255
Error: Release not found.
255256
"""
@@ -281,62 +282,62 @@ Feature: Download WordPress
281282
Scenario: Fail if path can't be created
282283
Given an empty directory
283284
And a non-directory-path file:
284-
"""
285-
"""
285+
"""
286+
"""
286287

287288
When I try `wp core download --path=non-directory-path`
288289
Then STDERR should contain:
289-
"""
290-
Failed to create directory
291-
"""
290+
"""
291+
Failed to create directory
292+
"""
292293
And STDERR should contain:
293-
"""
294-
/non-directory-path/
295-
"""
294+
"""
295+
/non-directory-path/
296+
"""
296297
And the return code should be 1
297298

298299
When I try `WP_CLI_STRICT_ARGS_MODE=1 wp core download --path=non-directory-path`
299300
Then STDERR should contain:
300-
"""
301-
Failed to create directory
302-
"""
301+
"""
302+
Failed to create directory
303+
"""
303304
And STDERR should contain:
304-
"""
305-
non-directory-path/
306-
"""
305+
"""
306+
non-directory-path/
307+
"""
307308
And the return code should be 1
308309

309310
When I try `WP_CLI_STRICT_ARGS_MODE=1 wp core download --path=non-directory-path\\`
310311
Then STDERR should contain:
311-
"""
312-
Failed to create directory
313-
"""
312+
"""
313+
Failed to create directory
314+
"""
314315
And STDERR should contain:
315-
"""
316-
non-directory-path/
317-
"""
316+
"""
317+
non-directory-path/
318+
"""
318319
And the return code should be 1
319320

320321
When I try `wp core download --path=/root-level-directory`
321322
Then STDERR should contain:
322-
"""
323-
Insufficient permission to create directory
324-
"""
323+
"""
324+
Insufficient permission to create directory
325+
"""
325326
And STDERR should contain:
326-
"""
327-
/root-level-directory/
328-
"""
327+
"""
328+
/root-level-directory/
329+
"""
329330
And the return code should be 1
330331

331332
When I try `WP_CLI_STRICT_ARGS_MODE=1 wp core download --path=/root-level-directory`
332333
Then STDERR should contain:
333-
"""
334-
Insufficient permission to create directory
335-
"""
334+
"""
335+
Insufficient permission to create directory
336+
"""
336337
And STDERR should contain:
337-
"""
338-
/root-level-directory/
339-
"""
338+
"""
339+
/root-level-directory/
340+
"""
340341
And the return code should be 1
341342

342343
Scenario: Core download without the full wp-content/plugins dir
@@ -366,9 +367,9 @@ Feature: Download WordPress
366367
And the wp-includes directory should exist
367368
And the wp-content/themes directory should exist
368369
And the wp-content/themes directory should be:
369-
"""
370-
index.php
371-
"""
370+
"""
371+
index.php
372+
"""
372373
And the wp-includes/js/tinymce/themes directory should exist
373374

374375
Scenario: Core download without the full wp-content/plugins dir should work non US locale
@@ -382,9 +383,9 @@ Feature: Download WordPress
382383
And the wp-includes directory should exist
383384
And the wp-content/plugins directory should exist
384385
And the wp-content/plugins directory should be:
385-
"""
386-
index.php
387-
"""
386+
"""
387+
index.php
388+
"""
388389
And the wp-includes/js/tinymce/plugins directory should exist
389390

390391
Scenario: Core download without the full wp-content/themes dir should work non US locale
@@ -398,9 +399,9 @@ Feature: Download WordPress
398399
And the wp-includes directory should exist
399400
And the wp-content/themes directory should exist
400401
And the wp-content/themes directory should be:
401-
"""
402-
index.php
403-
"""
402+
"""
403+
index.php
404+
"""
404405
And the wp-includes/js/tinymce/themes directory should exist
405406

406407
Scenario: Core download without the full wp-content/plugins dir should work if a version is set
@@ -414,14 +415,14 @@ Feature: Download WordPress
414415
And the wp-includes directory should exist
415416
And the wp-content/plugins directory should exist
416417
And the wp-content/plugins directory should be:
417-
"""
418-
index.php
419-
"""
418+
"""
419+
index.php
420+
"""
420421
And the wp-content/themes directory should exist
421422
And the wp-content/themes directory should be:
422-
"""
423-
index.php
424-
"""
423+
"""
424+
index.php
425+
"""
425426
And the wp-includes/js/tinymce/themes directory should exist
426427
And the wp-includes/js/tinymce/plugins directory should exist
427428

@@ -473,3 +474,13 @@ Feature: Download WordPress
473474
Error: Cannot use both --skip-content and --no-extract at the same time.
474475
"""
475476
And the return code should be 1
477+
478+
Scenario: Allow installing major version with trailing zero
479+
Given an empty directory
480+
481+
When I run `wp core download --version=6.7.0`
482+
Then STDOUT should contain:
483+
"""
484+
Success:
485+
"""
486+

0 commit comments

Comments
 (0)