Skip to content

Commit ae4105c

Browse files
authored
Merge pull request #440 from wp-cli/wp-php-requirements
Support requires and requires_php in plugin/theme list and update command
2 parents f0cebef + 47b062e commit ae4105c

File tree

8 files changed

+351
-46
lines changed

8 files changed

+351
-46
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"wp-cli/entity-command": "^1.3 || ^2",
2626
"wp-cli/language-command": "^2.0",
2727
"wp-cli/scaffold-command": "^1.2 || ^2",
28-
"wp-cli/wp-cli-tests": "^4"
28+
"wp-cli/wp-cli-tests": "^4.3.7"
2929
},
3030
"config": {
3131
"process-timeout": 7200,

features/plugin.feature

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,3 +810,98 @@ Feature: Manage WordPress plugins
810810
"""
811811
5.5
812812
"""
813+
814+
@require-wp-4.0
815+
Scenario: Show plugin update as unavailable if it doesn't meet WordPress requirements
816+
Given a WP install
817+
And a wp-content/plugins/example/example.php file:
818+
"""
819+
<?php
820+
/**
821+
* Plugin Name: Example Plugin
822+
* Version: 1.0.0
823+
* Requires at least: 3.7
824+
* Tested up to: 6.7
825+
"""
826+
827+
Given that HTTP requests to https://api.wordpress.org/plugins/update-check/1.1/ will respond with:
828+
"""
829+
HTTP/1.1 200 OK
830+
831+
{
832+
"plugins": [],
833+
"translations": [],
834+
"no_update": {
835+
"example/example.php": {
836+
"id": "w.org/plugins/example",
837+
"slug": "example",
838+
"plugin": "example/example.php",
839+
"new_version": "2.0.0",
840+
841+
"requires": "100",
842+
"requires_php": "7.2",
843+
"requires_plugins": [],
844+
"compatibility": []
845+
}
846+
}
847+
}
848+
"""
849+
850+
And I run `wp plugin list`
851+
Then STDOUT should be a table containing rows:
852+
| name | status | update | version | update_version | auto_update | requires | requires_php |
853+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 100 | 7.2 |
854+
855+
When I try `wp plugin update example`
856+
Then STDERR should contain:
857+
"""
858+
Warning: example: This update requires WordPress version 100
859+
"""
860+
861+
@require-wp-4.0
862+
Scenario: Show plugin update as unavailable if it doesn't meet PHP requirements
863+
Given a WP install
864+
And a wp-content/plugins/example/example.php file:
865+
"""
866+
<?php
867+
/**
868+
* Plugin Name: Example Plugin
869+
* Version: 1.0.0
870+
* Requires at least: 3.7
871+
* Tested up to: 6.7
872+
"""
873+
874+
Given that HTTP requests to https://api.wordpress.org/plugins/update-check/1.1/ will respond with:
875+
"""
876+
HTTP/1.1 200 OK
877+
878+
{
879+
"plugins": {
880+
"example/example.php": {
881+
"id": "w.org/plugins/example",
882+
"slug": "example",
883+
"plugin": "example/example.php",
884+
"new_version": "2.0.0",
885+
"requires": "3.7",
886+
"tested": "6.6",
887+
"requires_php": "100",
888+
"requires_plugins": [],
889+
"compatibility": []
890+
}
891+
},
892+
"translations": [],
893+
"no_update": []
894+
}
895+
"""
896+
897+
And I run `wp plugin list`
898+
Then STDOUT should be a table containing rows:
899+
| name | status | update | version | update_version | auto_update | requires | requires_php |
900+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 3.7 | 100 |
901+
902+
When I try `wp plugin update example`
903+
Then STDERR should contain:
904+
"""
905+
Warning: example: This update requires PHP version 100
906+
"""
907+

features/theme-update.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Feature: Update WordPress themes
3232
| name | version |
3333
| twentytwelve | 4.0 |
3434

35+
@require-wp-4.5
3536
Scenario: Not giving a slug on update should throw an error unless --all given
3637
Given a WP install
3738
And I run `wp theme path`

features/theme.feature

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ Feature: Manage WordPress themes
207207
And STDOUT should be empty
208208
And the return code should be 0
209209

210+
@require-wp-5.3
210211
Scenario: Flag `--skip-update-check` skips update check when running `wp theme list`
211212
Given a WP install
212213

@@ -218,8 +219,8 @@ Feature: Manage WordPress themes
218219

219220
When I run `wp theme list --fields=name,status,update`
220221
Then STDOUT should be a table containing rows:
221-
| name | status | update |
222-
| astra | inactive | available |
222+
| name | status | update |
223+
| astra | inactive | available |
223224

224225
When I run `wp transient delete update_themes --network`
225226
Then STDOUT should be:
@@ -229,8 +230,8 @@ Feature: Manage WordPress themes
229230

230231
When I run `wp theme list --fields=name,status,update --skip-update-check`
231232
Then STDOUT should be a table containing rows:
232-
| name | status | update |
233-
| astra | inactive | none |
233+
| name | status | update |
234+
| astra | inactive | none |
234235

235236
Scenario: Install a theme when the theme directory doesn't yet exist
236237
Given a WP install
@@ -284,6 +285,7 @@ Feature: Manage WordPress themes
284285
Theme updated successfully.
285286
"""
286287

288+
@require-wp-5.7
287289
Scenario: Enabling and disabling a theme
288290
Given a WP multisite install
289291
And I run `wp theme install moina`
@@ -379,6 +381,7 @@ Feature: Manage WordPress themes
379381
And STDOUT should be empty
380382
And the return code should be 1
381383

384+
@require-wp-5.7
382385
Scenario: Install and attempt to activate a child theme without its parent
383386
Given a WP install
384387
And I run `wp theme install moina-blog`
@@ -392,6 +395,7 @@ Feature: Manage WordPress themes
392395
And STDOUT should be empty
393396
And the return code should be 1
394397

398+
@require-wp-5.7
395399
Scenario: List an active theme with its parent
396400
Given a WP install
397401
And I run `wp theme install moina`
@@ -470,6 +474,7 @@ Feature: Manage WordPress themes
470474
twentytwelve,1.0,{UPDATE_VERSION},Updated
471475
"""
472476

477+
@require-wp-5.7
473478
Scenario: Automatically install parent theme for a child theme
474479
Given a WP install
475480

@@ -579,7 +584,7 @@ Feature: Manage WordPress themes
579584
Error: Parameter errors:
580585
Invalid value specified for 'status' (Filter the output by theme status.)
581586
"""
582-
587+
@require-wp-5.7
583588
Scenario: Parent theme is active when its child is active
584589
Given a WP install
585590
And I run `wp theme delete --all --force`
@@ -620,3 +625,91 @@ Feature: Manage WordPress themes
620625
Then STDOUT should be a table containing rows:
621626
| auto_update |
622627
| on |
628+
629+
Scenario: Show theme update as unavailable if it doesn't meet WordPress requirements
630+
Given a WP install
631+
And a wp-content/themes/example/style.css file:
632+
"""
633+
/*
634+
Theme Name: example
635+
Version: 1.0.0
636+
*/
637+
"""
638+
And a wp-content/themes/example/index.php file:
639+
"""
640+
<?php
641+
// Silence is golden.
642+
"""
643+
644+
Given that HTTP requests to https://api.wordpress.org/themes/update-check/1.1/ will respond with:
645+
"""
646+
HTTP/1.1 200 OK
647+
648+
{
649+
"themes": {
650+
"example": {
651+
"theme": "example",
652+
"new_version": "2.0.0",
653+
"requires": "100",
654+
"requires_php": "5.6"
655+
}
656+
},
657+
"translations": [],
658+
"no_update": []
659+
}
660+
"""
661+
662+
And I run `wp theme list`
663+
Then STDOUT should be a table containing rows:
664+
| name | status | update | version | update_version | auto_update | requires | requires_php |
665+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 100 | 5.6 |
666+
667+
When I try `wp theme update example`
668+
Then STDERR should contain:
669+
"""
670+
Warning: example: This update requires WordPress version 100
671+
"""
672+
673+
Scenario: Show theme update as unavailable if it doesn't meet PHP requirements
674+
Given a WP install
675+
And a wp-content/themes/example/style.css file:
676+
"""
677+
/*
678+
Theme Name: example
679+
Version: 1.0.0
680+
*/
681+
"""
682+
And a wp-content/themes/example/index.php file:
683+
"""
684+
<?php
685+
// Silence is golden.
686+
"""
687+
688+
Given that HTTP requests to https://api.wordpress.org/themes/update-check/1.1/ will respond with:
689+
"""
690+
HTTP/1.1 200 OK
691+
692+
{
693+
"themes": {
694+
"example": {
695+
"theme": "example",
696+
"new_version": "2.0.0",
697+
"requires": "3.7",
698+
"requires_php": "100"
699+
}
700+
},
701+
"translations": [],
702+
"no_update": []
703+
}
704+
"""
705+
706+
And I run `wp theme list`
707+
Then STDOUT should be a table containing rows:
708+
| name | status | update | version | update_version | auto_update | requires | requires_php |
709+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 3.7 | 100 |
710+
711+
When I try `wp theme update example`
712+
Then STDERR should contain:
713+
"""
714+
Warning: example: This update requires PHP version 100
715+
"""

features/upgradables.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Feature: Manage WordPress themes and plugins
33
Background:
44
Given an empty cache
55

6+
@require-wp-4.5
67
Scenario Outline: Installing, upgrading and deleting a theme or plugin
78
Given a WP install
89
And I run `wp <type> path`

0 commit comments

Comments
 (0)