Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/cron.php

    r51916 r52010  
    1717    private $plus_thirty_minutes;
    1818
    19     function set_up() {
     19    public function set_up() {
    2020        parent::set_up();
    2121        // Make sure the schedule is clear.
     
    2525    }
    2626
    27     function tear_down() {
     27    public function tear_down() {
    2828        // Make sure the schedule is clear.
    2929        _set_cron_array( array() );
     
    3131    }
    3232
    33     function test_wp_get_schedule_empty() {
     33    public function test_wp_get_schedule_empty() {
    3434        // Nothing scheduled.
    3535        $hook = __FUNCTION__;
     
    3737    }
    3838
    39     function test_schedule_event_single() {
     39    public function test_schedule_event_single() {
    4040        // Schedule an event and make sure it's returned by wp_next_scheduled().
    4141        $hook      = __FUNCTION__;
     
    5151    }
    5252
    53     function test_schedule_event_single_args() {
     53    public function test_schedule_event_single_args() {
    5454        // Schedule an event with arguments and make sure it's returned by wp_next_scheduled().
    5555        $hook      = 'event';
     
    6969    }
    7070
    71     function test_schedule_event() {
     71    public function test_schedule_event() {
    7272        // Schedule an event and make sure it's returned by wp_next_scheduled().
    7373        $hook      = __FUNCTION__;
     
    8383    }
    8484
    85     function test_schedule_event_args() {
     85    public function test_schedule_event_args() {
    8686        // Schedule an event and make sure it's returned by wp_next_scheduled().
    8787        $hook      = 'event';
     
    112112     * @covers ::wp_schedule_event
    113113     */
    114     function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
     114    public function test_wp_schedule_event_without_cron_option_does_not_throw_warning() {
    115115        delete_option( 'cron' );
    116116
     
    133133     * @covers ::wp_schedule_single_event
    134134     */
    135     function test_wp_schedule_single_event_without_cron_option() {
     135    public function test_wp_schedule_single_event_without_cron_option() {
    136136        delete_option( 'cron' );
    137137
     
    149149    }
    150150
    151     function test_unschedule_event() {
     151    public function test_unschedule_event() {
    152152        // Schedule an event and make sure it's returned by wp_next_scheduled().
    153153        $hook      = __FUNCTION__;
     
    163163    }
    164164
    165     function test_clear_schedule() {
     165    public function test_clear_schedule() {
    166166        $hook = __FUNCTION__;
    167167        $args = array( 'arg1' );
     
    190190    }
    191191
    192     function test_clear_undefined_schedule() {
     192    public function test_clear_undefined_schedule() {
    193193        $hook = __FUNCTION__;
    194194        $args = array( 'arg1' );
     
    202202    }
    203203
    204     function test_clear_schedule_multiple_args() {
     204    public function test_clear_schedule_multiple_args() {
    205205        $hook = __FUNCTION__;
    206206        $args = array( 'arg1', 'arg2' );
     
    231231     * @ticket 10468
    232232     */
    233     function test_clear_schedule_new_args() {
     233    public function test_clear_schedule_new_args() {
    234234        $hook       = __FUNCTION__;
    235235        $args       = array( 'arg1' );
     
    269269     * @ticket 18997
    270270     */
    271     function test_unschedule_hook() {
     271    public function test_unschedule_hook() {
    272272        $hook = __FUNCTION__;
    273273        $args = array( rand_str() );
     
    289289    }
    290290
    291     function test_unschedule_undefined_hook() {
     291    public function test_unschedule_undefined_hook() {
    292292        $hook           = __FUNCTION__;
    293293        $unrelated_hook = __FUNCTION__ . '_two';
     
    310310     * @ticket 6966
    311311     */
    312     function test_duplicate_event() {
     312    public function test_duplicate_event() {
    313313        // Duplicate events close together should be skipped.
    314314        $hook = __FUNCTION__;
     
    333333     * @ticket 6966
    334334     */
    335     function test_not_duplicate_event() {
     335    public function test_not_duplicate_event() {
    336336        // Duplicate events far apart should work normally.
    337337        $hook = __FUNCTION__;
     
    352352    }
    353353
    354     function test_not_duplicate_event_reversed() {
     354    public function test_not_duplicate_event_reversed() {
    355355        // Duplicate events far apart should work normally regardless of order.
    356356        $hook = __FUNCTION__;
     
    377377     * @ticket 32656
    378378     */
    379     function test_pre_schedule_event_filter() {
     379    public function test_pre_schedule_event_filter() {
    380380        $hook = __FUNCTION__;
    381381        $args = array( 'arg1' );
     
    385385        $expected = _get_cron_array();
    386386
    387         add_filter( 'pre_schedule_event', array( $this, '_filter_pre_schedule_event_filter' ), 10, 2 );
     387        add_filter( 'pre_schedule_event', array( $this, 'filter_pre_schedule_event_filter' ), 10, 2 );
    388388
    389389        $this->assertTrue( wp_schedule_single_event( $ts1, $hook, $args ) );
     
    411411     * Filter the scheduling of events to use the preflight array.
    412412     */
    413     function _filter_pre_schedule_event_filter( $null, $event ) {
     413    public function filter_pre_schedule_event_filter( $null, $event ) {
    414414        $key = md5( serialize( $event->args ) );
    415415
     
    429429     * @ticket 32656
    430430     */
    431     function test_pre_reschedule_event_filter() {
     431    public function test_pre_reschedule_event_filter() {
    432432        $hook = __FUNCTION__;
    433433        $ts1  = strtotime( '+30 minutes' );
     
    453453     * @ticket 32656
    454454     */
    455     function test_pre_unschedule_event_filter() {
     455    public function test_pre_unschedule_event_filter() {
    456456        $hook = __FUNCTION__;
    457457        $ts1  = strtotime( '+30 minutes' );
     
    477477     * @ticket 32656
    478478     */
    479     function test_pre_clear_scheduled_hook_filters() {
     479    public function test_pre_clear_scheduled_hook_filters() {
    480480        $hook = __FUNCTION__;
    481481        $ts1  = strtotime( '+30 minutes' );
     
    508508     * @ticket 32656
    509509     */
    510     function test_pre_scheduled_event_hooks() {
     510    public function test_pre_scheduled_event_hooks() {
    511511        add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) );
    512512
     
    525525    }
    526526
    527     function filter_pre_scheduled_event_hooks() {
     527    public function filter_pre_scheduled_event_hooks() {
    528528        return (object) array(
    529529            'hook'      => 'preflight_event',
     
    542542     * @ticket 45976.
    543543     */
    544     function test_get_scheduled_event_singles() {
     544    public function test_get_scheduled_event_singles() {
    545545        $hook    = __FUNCTION__;
    546546        $args    = array( 'arg1' );
     
    585585     * @ticket 45976.
    586586     */
    587     function test_get_scheduled_event_recurring() {
     587    public function test_get_scheduled_event_recurring() {
    588588        $hook     = __FUNCTION__;
    589589        $args     = array( 'arg1' );
     
    629629     * @ticket 45976.
    630630     */
    631     function test_get_scheduled_event_false() {
     631    public function test_get_scheduled_event_false() {
    632632        $hook = __FUNCTION__;
    633633        $args = array( 'arg1' );
     
    654654     * @ticket 44818
    655655     */
    656     function test_duplicate_past_event() {
     656    public function test_duplicate_past_event() {
    657657        $hook = __FUNCTION__;
    658658        $args = array( 'arg1' );
     
    681681     * @ticket 44818
    682682     */
    683     function test_duplicate_near_future_event() {
     683    public function test_duplicate_near_future_event() {
    684684        $hook = __FUNCTION__;
    685685        $args = array( 'arg1' );
     
    709709     * @ticket 44818
    710710     */
    711     function test_duplicate_future_event() {
     711    public function test_duplicate_future_event() {
    712712        $hook = __FUNCTION__;
    713713        $args = array( 'arg1' );
     
    733733     * @ticket 44818
    734734     */
    735     function test_not_duplicate_future_event() {
     735    public function test_not_duplicate_future_event() {
    736736        $hook = __FUNCTION__;
    737737        $args = array( 'arg1' );
Note: See TracChangeset for help on using the changeset viewer.