Skip to content

Commit ce488a6

Browse files
committed
Merge latest master
1 parent d5e861d commit ce488a6

File tree

9 files changed

+248
-32
lines changed

9 files changed

+248
-32
lines changed

.actrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Configuration file for nektos/act.
2+
# See https://github.com/nektos/act#configuration
3+
-P ubuntu-latest=shivammathur/node:latest

.github/workflows/code-quality.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Code Quality Checks
2+
3+
on: pull_request
4+
5+
jobs:
6+
7+
lint: #-----------------------------------------------------------------------
8+
name: Lint PHP files
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out source code
12+
uses: actions/checkout@v2
13+
14+
- name: Check existence of composer.json file
15+
id: check_composer_file
16+
uses: andstor/file-existence-action@v1
17+
with:
18+
files: "composer.json"
19+
20+
- name: Set up PHP envirnoment
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '7.4'
24+
tools: cs2pr
25+
26+
- name: Get Composer cache Directory
27+
if: steps.check_composer_file.outputs.files_exists == 'true'
28+
id: composer-cache
29+
run: |
30+
echo "::set-output name=dir::$(composer config cache-files-dir)"
31+
32+
- name: Use Composer cache
33+
if: steps.check_composer_file.outputs.files_exists == 'true'
34+
uses: actions/cache@v1
35+
with:
36+
path: ${{ steps['composer-cache'].outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-composer-
40+
41+
- name: Install dependencies
42+
if: steps.check_composer_file.outputs.files_exists == 'true'
43+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
44+
45+
- name: Check existence of vendor/bin/parallel-lint file
46+
id: check_linter_file
47+
uses: andstor/file-existence-action@v1
48+
with:
49+
files: "vendor/bin/parallel-lint"
50+
51+
- name: Run Linter
52+
if: steps.check_linter_file.outputs.files_exists == 'true'
53+
run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr
54+
55+
phpcs: #----------------------------------------------------------------------
56+
name: PHPCS
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Check out source code
61+
uses: actions/checkout@v2
62+
63+
- name: Check existence of composer.json & phpcs.xml.dist files
64+
id: check_files
65+
uses: andstor/file-existence-action@v1
66+
with:
67+
files: "composer.json, phpcs.xml.dist"
68+
69+
- name: Set up PHP envirnoment
70+
uses: shivammathur/setup-php@v2
71+
with:
72+
php-version: '7.4'
73+
tools: cs2pr
74+
75+
- name: Get Composer cache Directory
76+
if: steps.check_files.outputs.files_exists == 'true'
77+
id: composer-cache
78+
run: |
79+
echo "::set-output name=dir::$(composer config cache-files-dir)"
80+
81+
- name: Use Composer cache
82+
if: steps.check_files.outputs.files_exists == 'true'
83+
uses: actions/cache@v1
84+
with:
85+
path: ${{ steps.composer-cache.outputs.dir }}
86+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-composer-
89+
90+
- name: Install dependencies
91+
if: steps.check_files.outputs.files_exists == 'true'
92+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
93+
94+
- name: Check existence of vendor/bin/phpcs file
95+
id: check_phpcs_binary_file
96+
uses: andstor/file-existence-action@v1
97+
with:
98+
files: "vendor/bin/phpcs"
99+
100+
- name: Run PHPCS
101+
if: steps.check_phpcs_binary_file.outputs.files_exists == 'true'
102+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

.travis.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
sudo: false
2-
dist: trusty
1+
os: linux
2+
dist: xenial
33

44
language: php
55
php: 7.4
66

7+
services:
8+
- mysql
9+
710
notifications:
811
email:
912
on_success: never
@@ -45,11 +48,6 @@ script:
4548

4649
jobs:
4750
include:
48-
- stage: sniff
49-
script:
50-
- composer lint
51-
- composer phpcs
52-
env: BUILD=sniff
5351
- stage: test
5452
php: 7.4
5553
env: WP_VERSION=latest
@@ -71,10 +69,7 @@ jobs:
7169
- stage: test
7270
php: 5.6
7371
env: WP_VERSION=3.7.11
72+
dist: trusty
7473
- stage: test
7574
php: 5.6
7675
env: WP_VERSION=trunk
77-
- stage: test
78-
php: 5.4
79-
dist: precise
80-
env: WP_VERSION=5.1

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,27 @@ There are no additional fields.
311311
$ wp cron schedule list --fields=name --format=ids
312312
hourly twicedaily daily
313313

314+
315+
316+
### wp cron event unschedule
317+
318+
Unschedules all cron events for a given hook.
319+
320+
~~~
321+
wp cron event unschedule <hook>
322+
~~~
323+
324+
**OPTIONS**
325+
326+
<hook>
327+
Name of the hook for which all events should be unscheduled.
328+
329+
**EXAMPLES**
330+
331+
# Unschedule a cron event on given hook.
332+
$ wp cron event unschedule cron_test
333+
Success: Unscheduled 2 events with hook 'cron_test'.
334+
314335
## Installing
315336

316337
This package is included with WP-CLI itself, no additional installation necessary.
@@ -343,7 +364,7 @@ Once you've decided to commit the time to seeing your pull request through, [ple
343364

344365
## Support
345366

346-
Github issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
367+
GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support
347368

348369

349370
*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"cron event run",
3737
"cron event schedule",
3838
"cron schedule",
39-
"cron schedule list"
39+
"cron schedule list",
40+
"cron event unschedule"
4041
]
4142
},
4243
"autoload": {

features/cron-event.feature

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,34 @@ Feature: Manage WP Cron events
3737
"""
3838
Executed a total of 1 cron event
3939
"""
40+
41+
@require-wp-4.9.0
42+
Scenario: Unschedule cron event
43+
When I run `wp cron event schedule wp_cli_test_event_1 now hourly`
44+
And I try `wp cron event unschedule wp_cli_test_event_1`
45+
Then STDOUT should contain:
46+
"""
47+
Success: Unscheduled 1 event for hook 'wp_cli_test_event_1'.
48+
"""
49+
50+
When I run `wp cron event schedule wp_cli_test_event_2 now hourly`
51+
And I run `wp cron event schedule wp_cli_test_event_2 '+1 hour' hourly`
52+
And I try `wp cron event unschedule wp_cli_test_event_2`
53+
Then STDOUT should contain:
54+
"""
55+
Success: Unscheduled 2 events for hook 'wp_cli_test_event_2'.
56+
"""
57+
58+
When I try `wp cron event unschedule wp_cli_test_event`
59+
Then STDERR should be:
60+
"""
61+
Error: No events found for hook 'wp_cli_test_event'.
62+
"""
63+
64+
@less-than-wp-4.9.0
65+
Scenario: Unschedule cron event for WP < 4.9.0, wp_unschedule_hook was not included
66+
When I try `wp cron event unschedule wp_cli_test_event_1`
67+
Then STDERR should be:
68+
"""
69+
Error: Unscheduling events is only supported from WordPress 4.9.0 onwards.
70+
"""

features/cron.feature

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Feature: Manage WP-Cron events and schedules
55
And I run `wp config set DISABLE_WP_CRON false --raw --type=constant --anchor='// ** MySQL settings - You can get this info from your web host ** //'`
66

77
Scenario: Scheduling and then deleting an event
8-
When I run `wp cron event schedule wp_cli_test_event_1 '+1 hour 5 minutes' --apple=banana`
8+
When I run `wp cron event schedule wp_cli_test_event_1 '+1 hour 5 minutes' --0=banana`
99
Then STDOUT should contain:
1010
"""
1111
Success: Scheduled event with hook 'wp_cli_test_event_1'
1212
"""
1313

1414
When I run `wp cron event list --format=csv --fields=hook,recurrence,args`
1515
Then STDOUT should be CSV containing:
16-
| hook | recurrence | args |
17-
| wp_cli_test_event_1 | Non-repeating | {"apple":"banana"} |
16+
| hook | recurrence | args |
17+
| wp_cli_test_event_1 | Non-repeating | ["banana"] |
1818

1919
When I run `wp cron event list --fields=hook,next_run_relative | grep wp_cli_test_event_1`
2020
Then STDOUT should contain:
@@ -74,15 +74,15 @@ Feature: Manage WP-Cron events and schedules
7474
"""
7575

7676
Scenario: Scheduling, running, and deleting duplicate events
77-
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --apple=banana`
78-
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --foo=bar`
77+
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --0=banana`
78+
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --0=bar`
7979
Then STDOUT should not be empty
8080

8181
When I run `wp cron event list --format=csv --fields=hook,recurrence,args`
8282
Then STDOUT should be CSV containing:
83-
| hook | recurrence | args |
84-
| wp_cli_test_event_5 | Non-repeating | {"apple":"banana"} |
85-
| wp_cli_test_event_5 | Non-repeating | {"foo":"bar"} |
83+
| hook | recurrence | args |
84+
| wp_cli_test_event_5 | Non-repeating | ["banana"] |
85+
| wp_cli_test_event_5 | Non-repeating | ["bar"] |
8686

8787
When I run `wp cron event run wp_cli_test_event_5`
8888
Then STDOUT should contain:
@@ -110,8 +110,8 @@ Feature: Manage WP-Cron events and schedules
110110
Error: Invalid cron event 'wp_cli_test_event_5'
111111
"""
112112

113-
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --apple=banana`
114-
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --foo=bar`
113+
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --0=banana`
114+
When I run `wp cron event schedule wp_cli_test_event_5 '+20 minutes' --0=bar`
115115
Then STDOUT should not be empty
116116

117117
When I run `wp cron event list`
@@ -318,3 +318,16 @@ Feature: Manage WP-Cron events and schedules
318318
"""
319319
wp_cli_test_event_1 wp_cli_test_event_1
320320
"""
321+
322+
Scenario: Scheduling an event with non-numerically indexed arguments
323+
When I try `wp cron event schedule wp_cli_test_args_event '+10 minutes' --foo=banana --bar=apple`
324+
Then STDOUT should not be empty
325+
And STDERR should be:
326+
"""
327+
Warning: Numeric keys should be used for the hook arguments.
328+
"""
329+
330+
When I run `wp cron event list --format=csv --fields=hook,recurrence,args`
331+
Then STDOUT should be CSV containing:
332+
| hook | recurrence | args |
333+
| wp_cli_test_args_event | Non-repeating | {"foo":"banana","bar":"apple"} |

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<!-- For help understanding the `testVersion` configuration setting:
4040
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
41-
<config name="testVersion" value="5.4-"/>
41+
<config name="testVersion" value="5.6-"/>
4242

4343
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
4444
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->

0 commit comments

Comments
 (0)