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/general/wpGetDocumentTitle.php

    r51568 r52010  
    4444    }
    4545
    46     function set_up() {
     46    public function set_up() {
    4747        parent::set_up();
    4848
    49         add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
     49        add_action( 'after_setup_theme', array( $this, 'add_title_tag_support' ) );
    5050
    5151        $this->blog_name = get_option( 'blogname' );
     
    5454    }
    5555
    56     function _add_title_tag_support() {
     56    public function add_title_tag_support() {
    5757        add_theme_support( 'title-tag' );
    5858    }
    5959
    60     function test__wp_render_title_tag() {
     60    public function test__wp_render_title_tag() {
    6161        $this->go_to( '/' );
    6262
     
    6565    }
    6666
    67     function test__wp_render_title_no_theme_support() {
     67    public function test__wp_render_title_no_theme_support() {
    6868        $this->go_to( '/' );
    6969
     
    7474    }
    7575
    76     function test_short_circuiting_title() {
    77         $this->go_to( '/' );
    78 
    79         add_filter( 'pre_get_document_title', array( $this, '_short_circuit_title' ) );
     76    public function test_short_circuiting_title() {
     77        $this->go_to( '/' );
     78
     79        add_filter( 'pre_get_document_title', array( $this, 'short_circuit_title' ) );
    8080
    8181        $this->assertSame( 'A Wild Title', wp_get_document_title() );
    8282    }
    8383
    84     function _short_circuit_title( $title ) {
     84    public function short_circuit_title( $title ) {
    8585        return 'A Wild Title';
    8686    }
    8787
    88     function test_front_page_title() {
     88    public function test_front_page_title() {
    8989        update_option( 'show_on_front', 'page' );
    9090        update_option(
     
    9797            )
    9898        );
    99         add_filter( 'document_title_parts', array( $this, '_front_page_title_parts' ) );
     99        add_filter( 'document_title_parts', array( $this, 'front_page_title_parts' ) );
    100100
    101101        $this->go_to( '/' );
     
    108108    }
    109109
    110     function _front_page_title_parts( $parts ) {
     110    public function front_page_title_parts( $parts ) {
    111111        $this->assertArrayHasKey( 'title', $parts );
    112112        $this->assertArrayHasKey( 'tagline', $parts );
     
    116116    }
    117117
    118     function test_home_title() {
     118    public function test_home_title() {
    119119        $blog_page_id = $this->factory->post->create(
    120120            array(
     
    131131    }
    132132
    133     function test_paged_title() {
     133    public function test_paged_title() {
    134134        $this->go_to( '?page=4' );
    135135
    136         add_filter( 'document_title_parts', array( $this, '_paged_title_parts' ) );
     136        add_filter( 'document_title_parts', array( $this, 'paged_title_parts' ) );
    137137
    138138        $this->assertSame( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() );
    139139    }
    140140
    141     function _paged_title_parts( $parts ) {
     141    public function paged_title_parts( $parts ) {
    142142        $this->assertArrayHasKey( 'page', $parts );
    143143        $this->assertArrayHasKey( 'title', $parts );
     
    148148    }
    149149
    150     function test_singular_title() {
     150    public function test_singular_title() {
    151151        $this->go_to( '?p=' . self::$post_id );
    152152
    153         add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) );
     153        add_filter( 'document_title_parts', array( $this, 'singular_title_parts' ) );
    154154
    155155        $this->assertSame( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() );
    156156    }
    157157
    158     function _singular_title_parts( $parts ) {
     158    public function singular_title_parts( $parts ) {
    159159        $this->assertArrayHasKey( 'site', $parts );
    160160        $this->assertArrayHasKey( 'title', $parts );
     
    164164    }
    165165
    166     function test_category_title() {
     166    public function test_category_title() {
    167167        $this->go_to( '?cat=' . self::$category_id );
    168168
     
    170170    }
    171171
    172     function test_search_title() {
     172    public function test_search_title() {
    173173        $this->go_to( '?s=test_title' );
    174174
     
    176176    }
    177177
    178     function test_author_title() {
     178    public function test_author_title() {
    179179        $this->go_to( '?author=' . self::$author_id );
    180180
     
    182182    }
    183183
    184     function test_post_type_archive_title() {
     184    public function test_post_type_archive_title() {
    185185        register_post_type(
    186186            'cpt',
     
    205205    }
    206206
    207     function test_year_title() {
     207    public function test_year_title() {
    208208        $this->go_to( '?year=2015' );
    209209
     
    211211    }
    212212
    213     function test_month_title() {
     213    public function test_month_title() {
    214214        $this->go_to( '?monthnum=09' );
    215215
     
    217217    }
    218218
    219     function test_day_title() {
     219    public function test_day_title() {
    220220        $this->go_to( '?day=22' );
    221221
     
    223223    }
    224224
    225     function test_404_title() {
     225    public function test_404_title() {
    226226        $this->go_to( '?m=404' );
    227227
     
    229229    }
    230230
    231     function test_paged_post_title() {
     231    public function test_paged_post_title() {
    232232        $this->go_to( '?paged=4&p=' . self::$post_id );
    233233
    234         add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) );
     234        add_filter( 'title_tag_parts', array( $this, 'paged_post_title_parts' ) );
    235235
    236236        $this->assertSame( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() );
    237237    }
    238238
    239     function _paged_post_title_parts( $parts ) {
     239    public function paged_post_title_parts( $parts ) {
    240240        $this->assertArrayHasKey( 'page', $parts );
    241241        $this->assertArrayHasKey( 'site', $parts );
     
    246246    }
    247247
    248     function test_rearrange_title_parts() {
     248    public function test_rearrange_title_parts() {
    249249        $this->go_to( '?p=' . self::$post_id );
    250250
    251         add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) );
     251        add_filter( 'document_title_parts', array( $this, 'rearrange_title_parts' ) );
    252252
    253253        $this->assertSame( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() );
    254254    }
    255255
    256     function _rearrange_title_parts( $parts ) {
     256    public function rearrange_title_parts( $parts ) {
    257257        $parts = array(
    258258            $parts['site'],
     
    263263    }
    264264
    265     function test_change_title_separator() {
     265    public function test_change_title_separator() {
    266266        $this->go_to( '?p=' . self::$post_id );
    267267
    268         add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) );
     268        add_filter( 'document_title_separator', array( $this, 'change_title_separator' ) );
    269269
    270270        $this->assertSame( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() );
    271271    }
    272272
    273     function _change_title_separator( $sep ) {
     273    public function change_title_separator( $sep ) {
    274274        return '%%';
    275275    }
Note: See TracChangeset for help on using the changeset viewer.