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/theme/customHeader.php

    r51568 r52010  
    2020    }
    2121
    22     function set_up() {
     22    public function set_up() {
    2323        parent::set_up();
    2424
     
    3030    }
    3131
    32     function tear_down() {
     32    public function tear_down() {
    3333        $this->customize_manager = null;
    3434        unset( $GLOBALS['wp_customize'] );
     
    4343    }
    4444
    45     function test_add_and_remove_theme_support() {
    46         $this->_add_theme_support();
     45    public function test_add_and_remove_theme_support() {
     46        $this->add_theme_support();
    4747        $this->assertTrue( current_theme_supports( 'custom-header' ) );
    4848        remove_theme_support( 'custom-header' );
     
    5050    }
    5151
    52     function test_get_header_image_without_registered_default() {
    53         $this->_add_theme_support();
     52    public function test_get_header_image_without_registered_default() {
     53        $this->add_theme_support();
    5454        $image = get_header_image();
    5555        $this->assertFalse( has_header_image() );
     
    5757    }
    5858
    59     function test_get_header_image_with_registered_default() {
    60         $default = 'http://localhost/default-header.jpg';
    61         $this->_add_theme_support( array( 'default-image' => $default ) );
     59    public function test_get_header_image_with_registered_default() {
     60        $default = 'http://localhost/default-header.jpg';
     61        $this->add_theme_support( array( 'default-image' => $default ) );
    6262
    6363        $image = get_header_image();
     
    6666    }
    6767
    68     function test_get_header_image_from_theme_mod() {
     68    public function test_get_header_image_from_theme_mod() {
    6969        $default = 'http://localhost/default-header.jpg';
    7070        $custom  = 'http://localhost/custom-header.jpg';
    71         $this->_add_theme_support( array( 'default-image' => $default ) );
     71        $this->add_theme_support( array( 'default-image' => $default ) );
    7272
    7373        set_theme_mod( 'header_image', $custom );
     
    8282    }
    8383
    84     function test_get_header_image_tag_without_registered_default_image() {
    85         $this->_add_theme_support();
     84    public function test_get_header_image_tag_without_registered_default_image() {
     85        $this->add_theme_support();
    8686        $html = get_header_image_tag();
    8787        $this->assertEmpty( $html );
    8888    }
    8989
    90     function test_get_header_image_tag_with_registered_default_image() {
    91         $default = 'http://localhost/default-header.jpg';
    92         $this->_add_theme_support( array( 'default-image' => $default ) );
     90    public function test_get_header_image_tag_with_registered_default_image() {
     91        $default = 'http://localhost/default-header.jpg';
     92        $this->add_theme_support( array( 'default-image' => $default ) );
    9393
    9494        $html = get_header_image_tag();
     
    100100     * @ticket 38633
    101101     */
    102     function test_get_header_image_tag_with_registered_default_image_and_remove_header_theme_mod() {
    103         $default = 'http://localhost/default-header.jpg';
    104         $this->_add_theme_support( array( 'default-image' => $default ) );
     102    public function test_get_header_image_tag_with_registered_default_image_and_remove_header_theme_mod() {
     103        $default = 'http://localhost/default-header.jpg';
     104        $this->add_theme_support( array( 'default-image' => $default ) );
    105105
    106106        set_theme_mod( 'header_image', 'remove-header' );
     
    109109    }
    110110
    111     function test_get_header_image_tag_with_registered_default_image_and_custom_theme_mod() {
     111    public function test_get_header_image_tag_with_registered_default_image_and_custom_theme_mod() {
    112112        $default = 'http://localhost/default-header.jpg';
    113113        $custom  = 'http://localhost/custom-header.jpg';
    114         $this->_add_theme_support( array( 'default-image' => $default ) );
     114        $this->add_theme_support( array( 'default-image' => $default ) );
    115115
    116116        set_theme_mod( 'header_image', $custom );
     
    120120    }
    121121
    122     function test_get_custom_header_markup_without_registered_default_image() {
    123         $this->_add_theme_support();
     122    public function test_get_custom_header_markup_without_registered_default_image() {
     123        $this->add_theme_support();
    124124
    125125        $html = get_custom_header_markup();
     
    128128
    129129        // The container should always be returned in the Customizer preview.
    130         $this->_set_customize_previewing( true );
     130        $this->set_customize_previewing( true );
    131131        $html = get_custom_header_markup();
    132132        $this->assertSame( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html );
    133133    }
    134134
    135     function test_get_custom_header_markup_with_registered_default_image() {
    136         $default = 'http://localhost/default-header.jpg';
    137         $this->_add_theme_support( array( 'default-image' => $default ) );
     135    public function test_get_custom_header_markup_with_registered_default_image() {
     136        $default = 'http://localhost/default-header.jpg';
     137        $this->add_theme_support( array( 'default-image' => $default ) );
    138138        $html = get_custom_header_markup();
    139139        $this->assertTrue( has_custom_header() );
     
    142142    }
    143143
    144     function test_get_header_video_url() {
    145         $this->_add_theme_support( array( 'video' => true ) );
     144    public function test_get_header_video_url() {
     145        $this->add_theme_support( array( 'video' => true ) );
    146146
    147147        $this->assertFalse( has_header_video() );
     
    151151    }
    152152
    153     function test_get_external_header_video_url() {
     153    public function test_get_external_header_video_url() {
    154154        $external = 'http://example.com/custom-video.mp4';
    155         $this->_add_theme_support( array( 'video' => true ) );
     155        $this->add_theme_support( array( 'video' => true ) );
    156156
    157157        $this->assertFalse( has_header_video() );
     
    161161    }
    162162
    163     function test_get_header_video_url_prefers_local_video() {
     163    public function test_get_header_video_url_prefers_local_video() {
    164164        $external = 'http://example.com/custom-video.mp4';
    165         $this->_add_theme_support( array( 'video' => true ) );
     165        $this->add_theme_support( array( 'video' => true ) );
    166166
    167167        set_theme_mod( 'header_video', self::$header_video_id );
     
    170170    }
    171171
    172     function test_get_custom_header_markup_with_video_and_without_an_image() {
     172    public function test_get_custom_header_markup_with_video_and_without_an_image() {
    173173        $custom = 'http://localhost/custom-video.mp4';
    174         $this->_add_theme_support(
     174        $this->add_theme_support(
    175175            array(
    176176                'video'                 => true,
     
    186186    }
    187187
    188     function test_header_script_is_not_enqueued_by_the_custom_header_markup_without_video() {
    189         $this->_add_theme_support(
     188    public function test_header_script_is_not_enqueued_by_the_custom_header_markup_without_video() {
     189        $this->add_theme_support(
    190190            array(
    191191                'video'                 => true,
     
    207207    }
    208208
    209     function test_header_script_is_not_enqueued_by_the_custom_header_markup_when_active_callback_is_false() {
    210         $this->_add_theme_support(
     209    public function test_header_script_is_not_enqueued_by_the_custom_header_markup_when_active_callback_is_false() {
     210        $this->add_theme_support(
    211211            array(
    212212                'video'                 => true,
     
    222222    }
    223223
    224     function test_header_script_is_enqueued_by_the_custom_header_markup_without_video_when_previewing_in_customizer() {
    225         $this->_add_theme_support(
    226             array(
    227                 'video'                 => true,
    228                 'video-active-callback' => '__return_true',
    229             )
    230         );
    231         $this->_set_customize_previewing( true );
     224    public function test_header_script_is_enqueued_by_the_custom_header_markup_without_video_when_previewing_in_customizer() {
     225        $this->add_theme_support(
     226            array(
     227                'video'                 => true,
     228                'video-active-callback' => '__return_true',
     229            )
     230        );
     231        $this->set_customize_previewing( true );
    232232
    233233        ob_start();
     
    237237    }
    238238
    239     function test_header_script_is_enqueued_by_the_custom_header_markup_with_video() {
    240         $this->_add_theme_support(
     239    public function test_header_script_is_enqueued_by_the_custom_header_markup_with_video() {
     240        $this->add_theme_support(
    241241            array(
    242242                'video'                 => true,
     
    255255     * @ticket 38738
    256256     */
    257     function test_video_header_callback_front_page_from_front_page() {
    258         $this->_add_theme_support(
     257    public function test_video_header_callback_front_page_from_front_page() {
     258        $this->add_theme_support(
    259259            array(
    260260                'video' => true,
     
    272272     * @ticket 38738
    273273     */
    274     function test_video_header_callback_front_page_from_elsewhere() {
    275         $this->_add_theme_support(
     274    public function test_video_header_callback_front_page_from_elsewhere() {
     275        $this->add_theme_support(
    276276            array(
    277277                'video' => true,
     
    289289     * @ticket 38738
    290290     */
    291     function test_video_header_callback_globally_from_front_page() {
    292         $this->_add_theme_support(
     291    public function test_video_header_callback_globally_from_front_page() {
     292        $this->add_theme_support(
    293293            array(
    294294                'video'                 => true,
     
    307307     * @ticket 38738
    308308     */
    309     function test_video_header_callback_globally_from_elsewhere() {
    310         $this->_add_theme_support(
     309    public function test_video_header_callback_globally_from_elsewhere() {
     310        $this->add_theme_support(
    311311            array(
    312312                'video'                 => true,
     
    325325     * @ticket 38738
    326326     */
    327     function test_video_header_callback_globally_with_negative_filter() {
    328         $this->_add_theme_support(
     327    public function test_video_header_callback_globally_with_negative_filter() {
     328        $this->add_theme_support(
    329329            array(
    330330                'video'                 => true,
     
    347347     * it defines constants.
    348348     */
    349     function _add_theme_support( $args = array() ) {
     349    private function add_theme_support( $args = array() ) {
    350350        global $_wp_theme_features;
    351351
     
    371371    }
    372372
    373     function _set_customize_previewing( $value ) {
     373    private function set_customize_previewing( $value ) {
    374374        $class    = new ReflectionClass( 'WP_Customize_Manager' );
    375375        $property = $class->getProperty( 'previewing' );
Note: See TracChangeset for help on using the changeset viewer.