Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (4 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/filters.php

    r51403 r52010  
    88class Tests_Filters extends WP_UnitTestCase {
    99
    10     function test_simple_filter() {
     10    public function test_simple_filter() {
    1111        $a   = new MockAction();
    1212        $tag = __FUNCTION__;
     
    2626    }
    2727
    28     function test_remove_filter() {
     28    public function test_remove_filter() {
    2929        $a   = new MockAction();
    3030        $tag = __FUNCTION__;
     
    4646    }
    4747
    48     function test_has_filter() {
     48    public function test_has_filter() {
    4949            $tag  = __FUNCTION__;
    5050            $func = __FUNCTION__ . '_func';
     
    6161
    6262    // One tag with multiple filters.
    63     function test_multiple_filters() {
     63    public function test_multiple_filters() {
    6464        $a1  = new MockAction();
    6565        $a2  = new MockAction();
     
    7878    }
    7979
    80     function test_filter_args_1() {
     80    public function test_filter_args_1() {
    8181        $a    = new MockAction();
    8282        $tag  = __FUNCTION__;
     
    9393    }
    9494
    95     function test_filter_args_2() {
     95    public function test_filter_args_2() {
    9696        $a1   = new MockAction();
    9797        $a2   = new MockAction();
     
    118118    }
    119119
    120     function test_filter_priority() {
     120    public function test_filter_priority() {
    121121        $a   = new MockAction();
    122122        $tag = __FUNCTION__;
     
    149149    }
    150150
    151     function test_all_filter() {
     151    public function test_all_filter() {
    152152        $a    = new MockAction();
    153153        $tag1 = __FUNCTION__ . '_1';
     
    173173    }
    174174
    175     function test_remove_all_filter() {
     175    public function test_remove_all_filter() {
    176176        $a   = new MockAction();
    177177        $tag = __FUNCTION__;
     
    200200     * @ticket 20920
    201201     */
    202     function test_remove_all_filters_should_respect_the_priority_argument() {
     202    public function test_remove_all_filters_should_respect_the_priority_argument() {
    203203        $a   = new MockAction();
    204204        $tag = __FUNCTION__;
     
    219219     * @ticket 9886
    220220     */
    221     function test_filter_ref_array() {
     221    public function test_filter_ref_array() {
    222222        $obj = new stdClass();
    223223        $a   = new MockAction();
     
    238238     * @ticket 12723
    239239     */
    240     function test_filter_ref_array_result() {
     240    public function test_filter_ref_array_result() {
    241241        $obj = new stdClass();
    242242        $a   = new MockAction();
     
    265265    }
    266266
    267     function _self_removal( $tag ) {
    268         remove_action( $tag, array( $this, '_self_removal' ), 10, 1 );
    269         return $tag;
    270     }
    271 
    272267    /**
    273268     * @ticket 29070
    274269     */
    275     function test_has_filter_after_remove_all_filters() {
     270    public function test_has_filter_after_remove_all_filters() {
    276271        $a   = new MockAction();
    277272        $tag = __FUNCTION__;
     
    354349     */
    355350    public function test_current_priority() {
    356         add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 );
     351        add_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 );
    357352        do_action( 'test_current_priority' );
    358         remove_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 );
     353        remove_action( 'test_current_priority', array( $this, 'current_priority_action' ), 99 );
    359354
    360355        $this->assertSame( 99, $this->current_priority );
    361356    }
    362357
    363     public function _current_priority_action() {
     358    public function current_priority_action() {
    364359        global $wp_filter;
    365360        $this->current_priority = $wp_filter[ current_filter() ]->current_priority();
     
    370365     */
    371366    public function test_other_priority() {
    372         add_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 );
     367        add_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 );
    373368        do_action( 'test_current_priority' );
    374         remove_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 );
     369        remove_action( 'test_current_priority', array( $this, 'other_priority_action' ), 99 );
    375370
    376371        $this->assertFalse( $this->current_priority );
    377372    }
    378373
    379     public function _other_priority_action() {
     374    public function other_priority_action() {
    380375        global $wp_filter;
    381376        $this->current_priority = $wp_filter['the_content']->current_priority();
Note: See TracChangeset for help on using the changeset viewer.