Skip to content

Commit d106c26

Browse files
committed
WP/CronInterval: add tests for namespaced names
1 parent 32795a9 commit d106c26

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

WordPress/Tests/WP/CronIntervalUnitTest.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ add_filter( 'cron_schedules', function ( $schedules ) {
165165
class FQNConstants {
166166
public function add_schedules() {
167167
add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) ); // Ok: > 15 min.
168-
add_filter( 'cron_schedules', array( $this, 'add_eight_minute_schedule' ) ); // Warning: 8 min.
168+
\add_filter( 'cron_schedules', array( $this, 'add_eight_minute_schedule' ) ); // Warning: 8 min.
169169
add_filter( 'cron_schedules', array( $this, 'add_hundred_minute_schedule' ) ); // Warning: time undetermined.
170170
add_filter( 'cron_schedules', array( $this, 'sneaky_fake_wp_constant_schedule' ) ); // Warning: time undetermined.
171171
}
@@ -326,3 +326,11 @@ function first_class_six_min_schedule( $schedules ) {
326326
}
327327
add_filter( 'cron_schedules', first_class_six_min_schedule(...)); // Warning: 6 min.
328328
add_filter( 'cron_schedules', 'first_class_six_min_schedule'(...)); // Warning: 6 min.
329+
330+
/*
331+
* Safeguard correct handling of all types of namespaced function calls (except FQN global function call which is
332+
* handled above).
333+
*/
334+
MyNamespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok.
335+
\MyNamespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok.
336+
namespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok. The sniff should start flagging this once it can resolve relative namespaces.

0 commit comments

Comments
 (0)