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/rewrite.php

    r51568 r52010  
    99    private $home_url;
    1010
    11     function set_up() {
     11    public function set_up() {
    1212        parent::set_up();
    1313
     
    1818    }
    1919
    20     function tear_down() {
     20    public function tear_down() {
    2121        global $wp_rewrite;
    2222        $wp_rewrite->init();
     
    8686    }
    8787
    88     function test_url_to_postid() {
     88    public function test_url_to_postid() {
    8989
    9090        $id = self::factory()->post->create();
     
    9595    }
    9696
    97     function test_url_to_postid_set_url_scheme_https_to_http() {
     97    public function test_url_to_postid_set_url_scheme_https_to_http() {
    9898        $post_id   = self::factory()->post->create();
    9999        $permalink = get_permalink( $post_id );
     
    105105    }
    106106
    107     function test_url_to_postid_set_url_scheme_http_to_https() {
     107    public function test_url_to_postid_set_url_scheme_http_to_https() {
    108108        $_SERVER['HTTPS'] = 'on';
    109109
     
    125125     * @group ms-required
    126126     */
    127     function test_url_to_postid_of_http_site_when_current_site_uses_https() {
     127    public function test_url_to_postid_of_http_site_when_current_site_uses_https() {
    128128        $_SERVER['HTTPS'] = 'on';
    129129
     
    131131        $this->blog_id_35531 = self::factory()->blog->create();
    132132
    133         add_filter( 'home_url', array( $this, '_filter_http_home_url' ), 10, 4 );
     133        add_filter( 'home_url', array( $this, 'filter_http_home_url' ), 10, 4 );
    134134
    135135        switch_to_blog( $this->blog_id_35531 );
     
    142142
    143143        // Cleanup.
    144         remove_filter( 'home_url', array( $this, '_filter_http_home_url' ), 10 );
     144        remove_filter( 'home_url', array( $this, 'filter_http_home_url' ), 10 );
    145145
    146146        // Test the tests.
     
    161161     * @return string                  The complete home URL including scheme and path.
    162162     */
    163     function _filter_http_home_url( $url, $path, $orig_scheme, $_blog_id ) {
     163    public function filter_http_home_url( $url, $path, $orig_scheme, $_blog_id ) {
    164164        global $blog_id;
    165165
     
    171171    }
    172172
    173     function test_url_to_postid_custom_post_type() {
     173    public function test_url_to_postid_custom_post_type() {
    174174        delete_option( 'rewrite_rules' );
    175175
     
    183183    }
    184184
    185     function test_url_to_postid_hierarchical() {
     185    public function test_url_to_postid_hierarchical() {
    186186
    187187        $parent_id = self::factory()->post->create(
     
    203203    }
    204204
    205     function test_url_to_postid_hierarchical_with_matching_leaves() {
     205    public function test_url_to_postid_hierarchical_with_matching_leaves() {
    206206
    207207        $parent_id       = self::factory()->post->create(
     
    246246    }
    247247
    248     function test_url_to_postid_home_has_path() {
     248    public function test_url_to_postid_home_has_path() {
    249249
    250250        update_option( 'home', home_url( '/example/' ) );
     
    272272     * @ticket 30438
    273273     */
    274     function test_parse_request_home_path() {
     274    public function test_parse_request_home_path() {
    275275        $home_url = home_url( '/path/' );
    276276        update_option( 'home', $home_url );
     
    292292     * @ticket 30438
    293293     */
    294     function test_parse_request_home_path_with_regex_character() {
     294    public function test_parse_request_home_path_with_regex_character() {
    295295        $home_url       = home_url( '/ma.ch/' );
    296296        $not_a_home_url = home_url( '/match/' );
     
    329329     * @ticket 30018
    330330     */
    331     function test_parse_request_home_path_non_public_type() {
     331    public function test_parse_request_home_path_non_public_type() {
    332332        register_post_type( 'foo', array( 'public' => false ) );
    333333
     
    341341    }
    342342
    343     function test_url_to_postid_dupe_path() {
     343    public function test_url_to_postid_dupe_path() {
    344344        update_option( 'home', home_url( '/example/' ) );
    345345
     
    361361     * Reveals bug introduced in WP 3.0
    362362     */
    363     function test_url_to_postid_home_url_collision() {
     363    public function test_url_to_postid_home_url_collision() {
    364364        update_option( 'home', home_url( '/example' ) );
    365365
     
    382382     * @group ms-required
    383383     */
    384     function test_url_to_postid_ms_home_url_collision() {
     384    public function test_url_to_postid_ms_home_url_collision() {
    385385        $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) );
    386386        switch_to_blog( $blog_id );
     
    403403     * @ticket 21970
    404404     */
    405     function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() {
     405    public function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() {
    406406        $this->set_permalink_structure( '/%postname%/' );
    407407
     
    420420     * @ticket 34971
    421421     */
    422     function test_url_to_postid_static_front_page() {
     422    public function test_url_to_postid_static_front_page() {
    423423        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    424424
     
    454454     * @ticket 21970
    455455     */
    456     function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() {
     456    public function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() {
    457457        $this->set_permalink_structure( '/%postname%/' );
    458458
Note: See TracChangeset for help on using the changeset viewer.