mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 14:47:02 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -16,7 +16,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*/
|
||||
private $plus_thirty_minutes;
|
||||
|
||||
function set_up() {
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
// Make sure the schedule is clear.
|
||||
_set_cron_array( array() );
|
||||
@@ -24,19 +24,19 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->plus_thirty_minutes = strtotime( '+30 minutes' );
|
||||
}
|
||||
|
||||
function tear_down() {
|
||||
public function tear_down() {
|
||||
// Make sure the schedule is clear.
|
||||
_set_cron_array( array() );
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
function test_wp_get_schedule_empty() {
|
||||
public function test_wp_get_schedule_empty() {
|
||||
// Nothing scheduled.
|
||||
$hook = __FUNCTION__;
|
||||
$this->assertFalse( wp_get_schedule( $hook ) );
|
||||
}
|
||||
|
||||
function test_schedule_event_single() {
|
||||
public function test_schedule_event_single() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@@ -50,7 +50,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
function test_schedule_event_single_args() {
|
||||
public function test_schedule_event_single_args() {
|
||||
// Schedule an event with arguments and make sure it's returned by wp_next_scheduled().
|
||||
$hook = 'event';
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@@ -68,7 +68,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_get_schedule( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_schedule_event() {
|
||||
public function test_schedule_event() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$recur = 'hourly';
|
||||
@@ -82,7 +82,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $recur, wp_get_schedule( $hook ) );
|
||||
}
|
||||
|
||||
function test_schedule_event_args() {
|
||||
public function test_schedule_event_args() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = 'event';
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@@ -111,7 +111,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_schedule_event
|
||||
*/
|
||||
function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
|
||||
public function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
|
||||
delete_option( 'cron' );
|
||||
|
||||
// Verify that the cause of the error is in place.
|
||||
@@ -132,7 +132,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @covers ::wp_schedule_single_event
|
||||
*/
|
||||
function test_wp_schedule_single_event_without_cron_option() {
|
||||
public function test_wp_schedule_single_event_without_cron_option() {
|
||||
delete_option( 'cron' );
|
||||
|
||||
// Verify that the cause of the error is in place.
|
||||
@@ -148,7 +148,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertNotContains( false, get_option( 'cron' ), 'Resulting cron array contains the value "false"' );
|
||||
}
|
||||
|
||||
function test_unschedule_event() {
|
||||
public function test_unschedule_event() {
|
||||
// Schedule an event and make sure it's returned by wp_next_scheduled().
|
||||
$hook = __FUNCTION__;
|
||||
$timestamp = strtotime( '+1 hour' );
|
||||
@@ -162,7 +162,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
}
|
||||
|
||||
function test_clear_schedule() {
|
||||
public function test_clear_schedule() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
|
||||
@@ -189,7 +189,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_clear_undefined_schedule() {
|
||||
public function test_clear_undefined_schedule() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
|
||||
@@ -201,7 +201,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( 0, $hook_unscheduled );
|
||||
}
|
||||
|
||||
function test_clear_schedule_multiple_args() {
|
||||
public function test_clear_schedule_multiple_args() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1', 'arg2' );
|
||||
|
||||
@@ -230,7 +230,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 10468
|
||||
*/
|
||||
function test_clear_schedule_new_args() {
|
||||
public function test_clear_schedule_new_args() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$multi_hook = __FUNCTION__ . '_multi';
|
||||
@@ -268,7 +268,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 18997
|
||||
*/
|
||||
function test_unschedule_hook() {
|
||||
public function test_unschedule_hook() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( rand_str() );
|
||||
|
||||
@@ -288,7 +288,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_next_scheduled( $hook ) );
|
||||
}
|
||||
|
||||
function test_unschedule_undefined_hook() {
|
||||
public function test_unschedule_undefined_hook() {
|
||||
$hook = __FUNCTION__;
|
||||
$unrelated_hook = __FUNCTION__ . '_two';
|
||||
|
||||
@@ -309,7 +309,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 6966
|
||||
*/
|
||||
function test_duplicate_event() {
|
||||
public function test_duplicate_event() {
|
||||
// Duplicate events close together should be skipped.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@@ -332,7 +332,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 6966
|
||||
*/
|
||||
function test_not_duplicate_event() {
|
||||
public function test_not_duplicate_event() {
|
||||
// Duplicate events far apart should work normally.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@@ -351,7 +351,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) );
|
||||
}
|
||||
|
||||
function test_not_duplicate_event_reversed() {
|
||||
public function test_not_duplicate_event_reversed() {
|
||||
// Duplicate events far apart should work normally regardless of order.
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
@@ -376,7 +376,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_schedule_event_filter() {
|
||||
public function test_pre_schedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
@@ -384,7 +384,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
|
||||
$expected = _get_cron_array();
|
||||
|
||||
add_filter( 'pre_schedule_event', array( $this, '_filter_pre_schedule_event_filter' ), 10, 2 );
|
||||
add_filter( 'pre_schedule_event', array( $this, 'filter_pre_schedule_event_filter' ), 10, 2 );
|
||||
|
||||
$this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) );
|
||||
$this->assertTrue( wp_schedule_event( $ts2, 'hourly', $hook ) );
|
||||
@@ -410,7 +410,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
/**
|
||||
* Filter the scheduling of events to use the preflight array.
|
||||
*/
|
||||
function _filter_pre_schedule_event_filter( $null, $event ) {
|
||||
public function filter_pre_schedule_event_filter( $null, $event ) {
|
||||
$key = md5( serialize( $event->args ) );
|
||||
|
||||
$this->preflight_cron_array[ $event->timestamp ][ $event->hook ][ $key ] = array(
|
||||
@@ -428,7 +428,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_reschedule_event_filter() {
|
||||
public function test_pre_reschedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@@ -452,7 +452,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_unschedule_event_filter() {
|
||||
public function test_pre_unschedule_event_filter() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@@ -476,7 +476,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_clear_scheduled_hook_filters() {
|
||||
public function test_pre_clear_scheduled_hook_filters() {
|
||||
$hook = __FUNCTION__;
|
||||
$ts1 = strtotime( '+30 minutes' );
|
||||
|
||||
@@ -507,7 +507,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32656
|
||||
*/
|
||||
function test_pre_scheduled_event_hooks() {
|
||||
public function test_pre_scheduled_event_hooks() {
|
||||
add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) );
|
||||
|
||||
$actual = wp_get_scheduled_event( 'preflight_event', array(), $this->plus_thirty_minutes );
|
||||
@@ -524,7 +524,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected->timestamp, $actual2 );
|
||||
}
|
||||
|
||||
function filter_pre_scheduled_event_hooks() {
|
||||
public function filter_pre_scheduled_event_hooks() {
|
||||
return (object) array(
|
||||
'hook' => 'preflight_event',
|
||||
'timestamp' => $this->plus_thirty_minutes,
|
||||
@@ -541,7 +541,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_singles() {
|
||||
public function test_get_scheduled_event_singles() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts_late = strtotime( '+30 minutes' );
|
||||
@@ -584,7 +584,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_recurring() {
|
||||
public function test_get_scheduled_event_recurring() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts_late = strtotime( '+30 minutes' );
|
||||
@@ -628,7 +628,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 45976.
|
||||
*/
|
||||
function test_get_scheduled_event_false() {
|
||||
public function test_get_scheduled_event_false() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts = strtotime( '+3 minutes' );
|
||||
@@ -653,7 +653,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_past_event() {
|
||||
public function test_duplicate_past_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '-14 minutes' );
|
||||
@@ -680,7 +680,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_near_future_event() {
|
||||
public function test_duplicate_near_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+4 minutes' );
|
||||
@@ -708,7 +708,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_duplicate_future_event() {
|
||||
public function test_duplicate_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+15 minutes' );
|
||||
@@ -732,7 +732,7 @@ class Tests_Cron extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 44818
|
||||
*/
|
||||
function test_not_duplicate_future_event() {
|
||||
public function test_not_duplicate_future_event() {
|
||||
$hook = __FUNCTION__;
|
||||
$args = array( 'arg1' );
|
||||
$ts1 = strtotime( '+15 minutes' );
|
||||
|
||||
Reference in New Issue
Block a user