Skip to content

Commit c047cac

Browse files
authored
Fix PHPCS errors in Behat test files (#151)
1 parent 61687ca commit c047cac

2 files changed

Lines changed: 76 additions & 57 deletions

File tree

‎features/cron-event.feature‎

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,21 @@ Feature: Manage WP Cron events
9191
Scenario: Run cron event with a registered shutdown function
9292
Given a wp-content/mu-plugins/setup_shutdown_function.php file:
9393
"""
94-
add_action('mycron', function() {
95-
breakthings();
96-
});
97-
98-
register_shutdown_function(function() {
99-
$error = error_get_last();
100-
if ($error['type'] === E_ERROR) {
101-
WP_CLI::line('MY SHUTDOWN FUNCTION');
102-
}
103-
});
94+
add_action(
95+
'mycron',
96+
function () {
97+
breakthings();
98+
}
99+
);
100+
101+
register_shutdown_function(
102+
function () {
103+
$error = error_get_last();
104+
if ( $error['type'] === E_ERROR ) {
105+
WP_CLI::line( 'MY SHUTDOWN FUNCTION' );
106+
}
107+
}
108+
);
104109
"""
105110

106111
When I run `wp cron event schedule mycron now`
@@ -114,13 +119,18 @@ Feature: Manage WP Cron events
114119
Given a wp-content/mu-plugins/setup_shutdown_function_log.php file:
115120
"""
116121
<?php
117-
add_action('mycronlog', function() {
118-
breakthings();
119-
});
122+
add_action(
123+
'mycronlog',
124+
function () {
125+
breakthings();
126+
}
127+
);
120128
121-
register_shutdown_function(function() {
122-
error_log('LOG A SHUTDOWN FROM ERROR');
123-
});
129+
register_shutdown_function(
130+
function () {
131+
error_log( 'LOG A SHUTDOWN FROM ERROR' );
132+
}
133+
);
124134
"""
125135

126136
And I run `wp config set WP_DEBUG true --raw`
@@ -211,18 +221,21 @@ Feature: Manage WP Cron events
211221
<?php
212222
add_action( 'wp_cli_test_hook', 'wp_cli_test_function' );
213223
add_action( 'wp_cli_test_hook', array( 'MyTestClass', 'my_method' ) );
214-
add_action( 'wp_cli_test_hook_closure', function() {
215-
// Test closure
216-
} );
224+
add_action(
225+
'wp_cli_test_hook_closure',
226+
function () {
227+
// Test closure
228+
}
229+
);
217230
218231
function wp_cli_test_function() {
219-
// Test function
232+
// Test function
220233
}
221234
222235
class MyTestClass {
223-
public static function my_method() {
224-
// Test method
225-
}
236+
public static function my_method() {
237+
// Test method
238+
}
226239
}
227240
"""
228241

‎features/cron.feature‎

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ Feature: Manage WP-Cron events and schedules
142142
"""
143143
<?php
144144
add_filter(
145-
'cron_schedules',
146-
function( $schedules ) {
147-
$schedules['test_schedule'] = array(
148-
'interval' => 3600,
149-
'display' => __( 'Every Hour' ),
150-
);
151-
return $schedules;
152-
}
145+
'cron_schedules',
146+
function ( $schedules ) {
147+
$schedules['test_schedule'] = array(
148+
'interval' => 3600,
149+
'display' => __( 'Every Hour' ),
150+
);
151+
return $schedules;
152+
}
153153
);
154154
"""
155155

@@ -235,11 +235,14 @@ Feature: Manage WP-Cron events and schedules
235235
And a wp-content/mu-plugins/set_cron_site_url.php file:
236236
"""
237237
<?php
238-
add_filter( 'cron_request', static function ( $cron_request_array ) {
239-
$cron_request_array['url'] = 'http://localhost:8080';
240-
$cron_request_array['args']['sslverify'] = false;
241-
return $cron_request_array;
242-
} );
238+
add_filter(
239+
'cron_request',
240+
static function ( $cron_request_array ) {
241+
$cron_request_array['url'] = 'http://localhost:8080';
242+
$cron_request_array['args']['sslverify'] = false;
243+
return $cron_request_array;
244+
}
245+
);
243246
"""
244247

245248
When I run `wp cron event schedule wp_cli_test_event_1 '+1 hour 5 minutes' --0=banana`
@@ -390,11 +393,14 @@ Feature: Manage WP-Cron events and schedules
390393
And a wp-content/mu-plugins/set_cron_site_url.php file:
391394
"""
392395
<?php
393-
add_filter( 'cron_request', static function ( $cron_request_array ) {
394-
$cron_request_array['url'] = str_replace( site_url(), 'http://localhost:8081', $cron_request_array['url'] );
395-
$cron_request_array['args']['sslverify'] = false;
396-
return $cron_request_array;
397-
} );
396+
add_filter(
397+
'cron_request',
398+
static function ( $cron_request_array ) {
399+
$cron_request_array['url'] = str_replace( site_url(), 'http://localhost:8081', $cron_request_array['url'] );
400+
$cron_request_array['args']['sslverify'] = false;
401+
return $cron_request_array;
402+
}
403+
);
398404
"""
399405

400406
When I run `wp eval 'var_export( ALTERNATE_WP_CRON );'`
@@ -451,23 +457,23 @@ Feature: Manage WP-Cron events and schedules
451457
"""
452458
<?php
453459
$val = array(
454-
1647914509 => array(
455-
'postindexer_secondpass_cron' => array(
456-
'40cd750bba9870f18aada2478b24840a' => array(
457-
'schedule' => '5mins',
458-
'args' => array(),
459-
'interval' => 100,
460-
),
460+
1647914509 => array(
461+
'postindexer_secondpass_cron' => array(
462+
'40cd750bba9870f18aada2478b24840a' => array(
463+
'schedule' => '5mins',
464+
'args' => array(),
465+
'interval' => 100,
466+
),
467+
),
468+
),
469+
'wp_batch_split_terms' => array(
470+
1442323165 => array(
471+
'40cd750bba9870f18aada2478b24840a' => array(
472+
'schedule' => false,
473+
'args' => array(),
474+
),
475+
),
461476
),
462-
),
463-
'wp_batch_split_terms' => array(
464-
1442323165 => array(
465-
'40cd750bba9870f18aada2478b24840a' => array(
466-
'schedule' => false,
467-
'args' => array()
468-
)
469-
)
470-
)
471477
);
472478
update_option( 'cron', $val );
473479
"""

0 commit comments

Comments
 (0)