Skip to content

Commit b5b00c9

Browse files
committed
chore: update WP Coding Standards to 3.1
1 parent 1fd7f3a commit b5b00c9

18 files changed

+277
-95
lines changed

__tests__/bootstrap.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function _manually_load_plugin() {
3232
)
3333
);
3434

35-
require_once dirname( dirname( __FILE__ ) ) . '/cron-control.php';
35+
require_once dirname( __DIR__ ) . '/cron-control.php';
3636

3737
// Plugin loads after `wp_install()` is called, so we compensate.
3838
if ( ! Cron_Control\Events_Store::is_installed() ) {
@@ -53,13 +53,13 @@ function _manually_load_plugin() {
5353
define( 'WP_CLI_ROOT', __DIR__ . '/../vendor/wp-cli/wp-cli' );
5454
}
5555

56-
include_once WP_CLI_ROOT . '/php/utils.php';
57-
include_once WP_CLI_ROOT . '/php/dispatcher.php';
58-
include_once WP_CLI_ROOT . '/php/class-wp-cli.php';
59-
include_once WP_CLI_ROOT . '/php/class-wp-cli-command.php';
56+
require_once WP_CLI_ROOT . '/php/utils.php';
57+
require_once WP_CLI_ROOT . '/php/dispatcher.php';
58+
require_once WP_CLI_ROOT . '/php/class-wp-cli.php';
59+
require_once WP_CLI_ROOT . '/php/class-wp-cli-command.php';
6060

6161
\WP_CLI\Utils\load_dependencies();
6262

6363
// WP_CLI wasn't defined during plugin bootup, so bootstrap our cli classes manually
64-
require_once dirname( dirname( __FILE__ ) ) . '/includes/wp-cli.php';
64+
require_once dirname( __DIR__ ) . '/includes/wp-cli.php';
6565
Cron_Control\CLI\prepare_environment();

__tests__/unit-tests/test-event.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function test_validate_props() {
151151
// Invalid status.
152152
$this->run_event_save_test( [
153153
'creation' => [
154-
'args' => [
154+
'args' => [
155155
'timestamp' => 1637447873,
156156
'action' => 'test_event',
157157
'status' => 'invalid_status',
@@ -163,7 +163,7 @@ public function test_validate_props() {
163163
// Invalid/missing action.
164164
$this->run_event_save_test( [
165165
'creation' => [
166-
'args' => [
166+
'args' => [
167167
'timestamp' => 1637447873,
168168
'action' => '',
169169
],
@@ -174,15 +174,15 @@ public function test_validate_props() {
174174
// Missing timestamp.
175175
$this->run_event_save_test( [
176176
'creation' => [
177-
'args' => [ 'action' => 'test_event' ],
177+
'args' => [ 'action' => 'test_event' ],
178178
'result' => new WP_Error( 'cron-control:event:prop-validation:invalid-timestamp' ),
179179
],
180180
] );
181181

182182
// Invalid timestamp.
183183
$this->run_event_save_test( [
184184
'creation' => [
185-
'args' => [
185+
'args' => [
186186
'timestamp' => -100,
187187
'action' => 'test_event',
188188
],
@@ -193,7 +193,7 @@ public function test_validate_props() {
193193
// Invalid schedule.
194194
$this->run_event_save_test( [
195195
'creation' => [
196-
'args' => [
196+
'args' => [
197197
'timestamp' => 1637447873,
198198
'action' => 'test_event',
199199
'schedule' => '',
@@ -206,7 +206,7 @@ public function test_validate_props() {
206206
// Invalid interval.
207207
$this->run_event_save_test( [
208208
'creation' => [
209-
'args' => [
209+
'args' => [
210210
'timestamp' => 1637447873,
211211
'action' => 'test_event',
212212
'schedule' => 'hourly',
@@ -223,7 +223,7 @@ public function test_event_save() {
223223
// Then update the timestamp.
224224
$this->run_event_save_test( [
225225
'creation' => [
226-
'args' => [
226+
'args' => [
227227
'action' => 'test_event_creations_1',
228228
'timestamp' => 1637447872,
229229
],
@@ -236,8 +236,8 @@ public function test_event_save() {
236236
'timestamp' => 1637447872,
237237
],
238238
],
239-
'update' => [
240-
'args' => [ 'timestamp' => 1637447872 + 500 ],
239+
'update' => [
240+
'args' => [ 'timestamp' => 1637447872 + 500 ],
241241
'result' => [
242242
'status' => 'pending',
243243
'action' => 'test_event_creations_1',
@@ -253,7 +253,7 @@ public function test_event_save() {
253253
// Then try to update with invalid timestamp
254254
$this->run_event_save_test( [
255255
'creation' => [
256-
'args' => [
256+
'args' => [
257257
'status' => 'complete',
258258
'action' => 'test_event_creations_2',
259259
'args' => [ 'some' => 'data' ],
@@ -270,8 +270,8 @@ public function test_event_save() {
270270
'timestamp' => 1637447873,
271271
],
272272
],
273-
'update' => [
274-
'args' => [ 'timestamp' => -1 ],
273+
'update' => [
274+
'args' => [ 'timestamp' => -1 ],
275275
'result' => new WP_Error( 'cron-control:event:prop-validation:invalid-timestamp' ),
276276
],
277277
] );

__tests__/unit-tests/test-events-store.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ public function test_query_raw_events() {
122122
$store = Events_Store::instance();
123123

124124
$args = [
125-
'status' => Events_Store::STATUS_PENDING,
126-
'action' => 'test_query_raw_events',
127-
'args' => [ 'some' => 'data' ],
128-
'schedule' => 'hourly',
129-
'interval' => HOUR_IN_SECONDS,
125+
'status' => Events_Store::STATUS_PENDING,
126+
'action' => 'test_query_raw_events',
127+
'args' => [ 'some' => 'data' ],
128+
'schedule' => 'hourly',
129+
'interval' => HOUR_IN_SECONDS,
130130
];
131131

132132
$event_one = Utils::create_test_event( array_merge( $args, [ 'timestamp' => 1 ] ) );

__tests__/unit-tests/test-events.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ public function test_format_events_for_wp() {
4141
$events['A']->get_action() => [ // A & B share action
4242
$events['A']->get_instance() => [
4343
'schedule' => false,
44-
'args' => [],
44+
'args' => [],
4545
],
4646
$events['B']->get_instance() => [
4747
'schedule' => 'hourly',
4848
'interval' => HOUR_IN_SECONDS,
49-
'args' => [ 'B' ],
49+
'args' => [ 'B' ],
5050
],
5151
],
5252
$events['C']->get_action() => [ // C has it's own action
5353
$events['C']->get_instance() => [
5454
'schedule' => false,
55-
'args' => [ 'C' ],
55+
'args' => [ 'C' ],
5656
],
5757
],
5858
],
5959
$events['D']->get_timestamp() => [ // D is on it's own since the timestamp is unique.
6060
$events['D']->get_action() => [
6161
$events['D']->get_instance() => [
6262
'schedule' => false,
63-
'args' => [ 'D' ],
63+
'args' => [ 'D' ],
6464
],
6565
],
6666
],
@@ -91,25 +91,25 @@ private function create_test_events() {
9191

9292
$events_to_create = [
9393
'A' => [
94-
'action' => 'test_format_events_for_wp',
95-
'args' => [],
94+
'action' => 'test_format_events_for_wp',
95+
'args' => [],
9696
'timestamp' => $time_one,
9797
],
9898
'B' => [
99-
'action' => 'test_format_events_for_wp',
100-
'args' => [ 'B' ],
99+
'action' => 'test_format_events_for_wp',
100+
'args' => [ 'B' ],
101101
'timestamp' => $time_one,
102-
'schedule' => 'hourly',
103-
'interval' => HOUR_IN_SECONDS,
102+
'schedule' => 'hourly',
103+
'interval' => HOUR_IN_SECONDS,
104104
],
105105
'C' => [
106-
'action' => 'test_format_events_for_wp_two',
107-
'args' => [ 'C' ],
106+
'action' => 'test_format_events_for_wp_two',
107+
'args' => [ 'C' ],
108108
'timestamp' => $time_one,
109109
],
110110
'D' => [
111-
'action' => 'test_format_events_for_wp',
112-
'args' => [ 'D' ],
111+
'action' => 'test_format_events_for_wp',
112+
'args' => [ 'D' ],
113113
'timestamp' => $time_two,
114114
],
115115
];

__tests__/unit-tests/test-rest-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setUp(): void {
1515
parent::setUp();
1616

1717
global $wp_rest_server;
18-
$wp_rest_server = new WP_REST_Server;
18+
$wp_rest_server = new WP_REST_Server();
1919
$this->server = $wp_rest_server;
2020
do_action( 'rest_api_init' );
2121

@@ -77,14 +77,14 @@ public function test_get_items() {
7777

7878
$this->assertResponseData(
7979
array(
80-
'events' => array(
80+
'events' => array(
8181
array(
8282
'timestamp' => $event->get_timestamp(),
8383
'action' => md5( $event->get_action() ),
8484
'instance' => $event->get_instance(),
8585
),
8686
),
87-
'endpoint' => get_rest_url( null, REST_API::API_NAMESPACE . '/' . REST_API::ENDPOINT_RUN ),
87+
'endpoint' => get_rest_url( null, REST_API::API_NAMESPACE . '/' . REST_API::ENDPOINT_RUN ),
8888
'total_events_pending' => 1,
8989
),
9090
$response

__tests__/unit-tests/test-wp-adapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ public function test_pre_clear_scheduled_hook() {
128128

129129
// Ensure the event update made it's way to the DB.
130130
$object = Event::find( [
131-
'action' => 'test_pre_clear_scheduled_hook',
131+
'action' => 'test_pre_clear_scheduled_hook',
132132
'timestamp' => $event_two['timestamp'],
133-
'status' => Events_Store::STATUS_COMPLETED,
133+
'status' => Events_Store::STATUS_COMPLETED,
134134
] );
135135
$this->assertEquals( Events_Store::STATUS_COMPLETED, $object->get_status() );
136136

@@ -250,7 +250,7 @@ public function test_pre_update_cron_option() {
250250

251251
$event_to_add = Utils::create_unsaved_event( array_merge( $default_args, [ 'action' => 'test_pre_update_cron_option_new' ] ) );
252252
$recurring_event_to_add = Utils::create_unsaved_event( array_merge( $default_args, [
253-
'action' => 'test_pre_update_cron_option_new_recurring',
253+
'action' => 'test_pre_update_cron_option_new_recurring',
254254
'schedule' => 'hourly',
255255
'interval' => HOUR_IN_SECONDS,
256256
] ) );

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"johnpbloch/wordpress-core": "^6.1.1",
1111
"phpcompatibility/phpcompatibility-wp": "^2.1.4",
1212
"wp-cli/wp-cli": "*",
13-
"wp-coding-standards/wpcs": "^2.3",
13+
"wp-coding-standards/wpcs": "^3.1",
1414
"wp-phpunit/wp-phpunit": "^6.1.1",
1515
"yoast/phpunit-polyfills": "^4.0.0"
1616
},

0 commit comments

Comments
 (0)