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/query/conditionals.php

    r51568 r52010  
    1515    protected $post_ids;
    1616
    17     function set_up() {
     17    public function set_up() {
    1818        parent::set_up();
    1919
     
    2626    }
    2727
    28     function test_home() {
     28    public function test_home() {
    2929        $this->go_to( '/' );
    3030        $this->assertQueryTrue( 'is_home', 'is_front_page' );
    3131    }
    3232
    33     function test_page_on_front() {
     33    public function test_page_on_front() {
    3434        $page_on_front  = self::factory()->post->create(
    3535            array(
     
    5757    }
    5858
    59     function test_404() {
     59    public function test_404() {
    6060        $this->go_to( '/notapage' );
    6161        $this->assertQueryTrue( 'is_404' );
    6262    }
    6363
    64     function test_permalink() {
     64    public function test_permalink() {
    6565        $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    6666        $this->go_to( get_permalink( $post_id ) );
     
    6868    }
    6969
    70     function test_post_comments_feed() {
     70    public function test_post_comments_feed() {
    7171        $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    7272        self::factory()->comment->create_post_comments( $post_id, 2 );
     
    7676
    7777
    78     function test_post_comments_feed_with_no_comments() {
     78    public function test_post_comments_feed_with_no_comments() {
    7979        $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    8080        $this->go_to( get_post_comments_feed_link( $post_id ) );
     
    8282    }
    8383
    84     function test_attachment_comments_feed() {
     84    public function test_attachment_comments_feed() {
    8585        $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    8686        self::factory()->comment->create_post_comments( $attachment_id, 2 );
     
    8989    }
    9090
    91     function test_page() {
     91    public function test_page() {
    9292        $page_id = self::factory()->post->create(
    9393            array(
     
    100100    }
    101101
    102     function test_parent_page() {
     102    public function test_parent_page() {
    103103        $page_id = self::factory()->post->create(
    104104            array(
     
    112112    }
    113113
    114     function test_child_page_1() {
     114    public function test_child_page_1() {
    115115        $page_id = self::factory()->post->create(
    116116            array(
     
    131131    }
    132132
    133     function test_child_page_2() {
     133    public function test_child_page_2() {
    134134        $page_id = self::factory()->post->create(
    135135            array(
     
    158158
    159159    // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1'
    160     function test_page_trackback() {
     160    public function test_page_trackback() {
    161161        $page_ids   = array();
    162162        $page_id    = self::factory()->post->create(
     
    196196
    197197    // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
    198     function test_page_feed() {
     198    public function test_page_feed() {
    199199        $page_ids   = array();
    200200        $page_id    = self::factory()->post->create(
     
    234234    }
    235235
    236     function test_page_feed_with_no_comments() {
     236    public function test_page_feed_with_no_comments() {
    237237        $page_ids   = array();
    238238        $page_id    = self::factory()->post->create(
     
    272272
    273273    // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
    274     function test_page_feed_atom() {
     274    public function test_page_feed_atom() {
    275275        $page_ids   = array();
    276276        $page_id    = self::factory()->post->create(
     
    312312
    313313    // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
    314     function test_page_page_2() {
     314    public function test_page_page_2() {
    315315        $page_id = self::factory()->post->create(
    316316            array(
     
    331331
    332332    // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
    333     function test_page_page_2_no_slash() {
     333    public function test_page_page_2_no_slash() {
    334334        $page_id = self::factory()->post->create(
    335335            array(
     
    350350
    351351    // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
    352     function test_pagination_of_posts_page() {
     352    public function test_pagination_of_posts_page() {
    353353        $page_id = self::factory()->post->create(
    354354            array(
     
    381381    // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
    382382    // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
    383     function test_main_feed_2() {
     383    public function test_main_feed_2() {
    384384        self::factory()->post->create(); // @test_404
    385385        $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
     
    399399    }
    400400
    401     function test_main_feed() {
     401    public function test_main_feed() {
    402402        self::factory()->post->create(); // @test_404
    403403        $types = array( 'rss2', 'rss', 'atom' );
     
    409409
    410410    // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
    411     function test_paged() {
     411    public function test_paged() {
    412412        update_option( 'posts_per_page', 2 );
    413413        self::factory()->post->create_many( 5 );
     
    420420    // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
    421421    // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
    422     function test_main_comments_feed() {
     422    public function test_main_comments_feed() {
    423423        $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    424424        self::factory()->comment->create_post_comments( $post_id, 2 );
     
    446446    // 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]',
    447447    // 'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]',
    448     function test_search_feed() {
     448    public function test_search_feed() {
    449449        // Check the long form.
    450450        $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
     
    463463
    464464    // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
    465     function test_search_paged() {
     465    public function test_search_paged() {
    466466        update_option( 'posts_per_page', 2 );
    467467        self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) );
     
    471471
    472472    // 'search/(.+)/?$' => 'index.php?s=$matches[1]',
    473     function test_search() {
     473    public function test_search() {
    474474        $this->go_to( '/search/test/' );
    475475        $this->assertQueryTrue( 'is_search' );
     
    479479     * @ticket 13961
    480480     */
    481     function test_search_encoded_chars() {
     481    public function test_search_encoded_chars() {
    482482        $this->go_to( '/search/F%C3%BCnf%2Bbar/' );
    483483        $this->assertSame( get_query_var( 's' ), 'Fünf+bar' );
     
    486486    // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
    487487    // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
    488     function test_category_feed() {
     488    public function test_category_feed() {
    489489        self::factory()->term->create(
    490490            array(
     
    510510
    511511    // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
    512     function test_category_paged() {
     512    public function test_category_paged() {
    513513        update_option( 'posts_per_page', 2 );
    514514        self::factory()->post->create_many( 3 );
     
    518518
    519519    // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
    520     function test_category() {
     520    public function test_category() {
    521521        self::factory()->term->create(
    522522            array(
     
    531531    // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
    532532    // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
    533     function test_tag_feed() {
     533    public function test_tag_feed() {
    534534        self::factory()->term->create(
    535535            array(
     
    554554
    555555    // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
    556     function test_tag_paged() {
     556    public function test_tag_paged() {
    557557        update_option( 'posts_per_page', 2 );
    558558        $post_ids = self::factory()->post->create_many( 3 );
     
    565565
    566566    // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
    567     function test_tag() {
     567    public function test_tag() {
    568568        $term_id = self::factory()->term->create(
    569569            array(
     
    590590    // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
    591591    // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
    592     function test_author_feed() {
     592    public function test_author_feed() {
    593593        self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    594594        // Check the long form.
     
    608608
    609609    // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
    610     function test_author_paged() {
     610    public function test_author_paged() {
    611611        update_option( 'posts_per_page', 2 );
    612612        $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
     
    617617
    618618    // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
    619     function test_author() {
     619    public function test_author() {
    620620        $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    621621        self::factory()->post->create( array( 'post_author' => $user_id ) );
     
    624624    }
    625625
    626     function test_author_with_no_posts() {
     626    public function test_author_with_no_posts() {
    627627        $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    628628        $this->go_to( '/author/user-a/' );
     
    632632    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
    633633    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
    634     function test_ymd_feed() {
     634    public function test_ymd_feed() {
    635635        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    636636        // Check the long form.
     
    650650
    651651    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]',
    652     function test_ymd_paged() {
     652    public function test_ymd_paged() {
    653653        update_option( 'posts_per_page', 2 );
    654654        self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     
    658658
    659659    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
    660     function test_ymd() {
     660    public function test_ymd() {
    661661        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    662662        $this->go_to( '/2007/09/04/' );
     
    666666    // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
    667667    // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
    668     function test_ym_feed() {
     668    public function test_ym_feed() {
    669669        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    670670        // Check the long form.
     
    684684
    685685    // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
    686     function test_ym_paged() {
     686    public function test_ym_paged() {
    687687        update_option( 'posts_per_page', 2 );
    688688        self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     
    692692
    693693    // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
    694     function test_ym() {
     694    public function test_ym() {
    695695        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    696696        $this->go_to( '/2007/09/' );
     
    700700    // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
    701701    // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
    702     function test_y_feed() {
     702    public function test_y_feed() {
    703703        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    704704        // Check the long form.
     
    718718
    719719    // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
    720     function test_y_paged() {
     720    public function test_y_paged() {
    721721        update_option( 'posts_per_page', 2 );
    722722        self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     
    726726
    727727    // '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
    728     function test_y() {
     728    public function test_y() {
    729729        self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    730730        $this->go_to( '/2007/' );
     
    733733
    734734    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1',
    735     function test_post_trackback() {
     735    public function test_post_trackback() {
    736736        $post_id   = self::factory()->post->create();
    737737        $permalink = get_permalink( $post_id );
     
    742742    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
    743743    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
    744     function test_post_comment_feed() {
     744    public function test_post_comment_feed() {
    745745        $post_id   = self::factory()->post->create();
    746746        $permalink = get_permalink( $post_id );
     
    761761
    762762    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]',
    763     function test_post_paged_short() {
     763    public function test_post_paged_short() {
    764764        $post_id = self::factory()->post->create(
    765765            array(
     
    776776
    777777    // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
    778     function test_post_attachment() {
     778    public function test_post_attachment() {
    779779        $post_id   = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    780780        $permalink = get_attachment_link( $post_id );
     
    794794     * @expectedIncorrectUsage WP_Date_Query
    795795     */
    796     function test_bad_dates() {
     796    public function test_bad_dates() {
    797797        $this->go_to( '/2013/13/13/' );
    798798        $this->assertQueryTrue( 'is_404' );
     
    802802    }
    803803
    804     function test_post_type_archive_with_tax_query() {
     804    public function test_post_type_archive_with_tax_query() {
    805805        delete_option( 'rewrite_rules' );
    806806
     
    833833    }
    834834
    835     function pre_get_posts_with_tax_query( &$query ) {
     835    public function pre_get_posts_with_tax_query( &$query ) {
    836836        $term = get_term_by( 'slug', 'tag-slug', 'post_tag' );
    837837        $query->set(
     
    847847    }
    848848
    849     function test_post_type_array() {
     849    public function test_post_type_array() {
    850850        delete_option( 'rewrite_rules' );
    851851
     
    875875    }
    876876
    877     function pre_get_posts_with_type_array( &$query ) {
     877    public function pre_get_posts_with_type_array( &$query ) {
    878878        $query->set( 'post_type', array( 'post', 'thearray' ) );
    879879    }
    880880
    881     function test_is_single() {
     881    public function test_is_single() {
    882882        $post_id = self::factory()->post->create();
    883883        $this->go_to( "/?p=$post_id" );
     
    899899     * @ticket 16802
    900900     */
    901     function test_is_single_with_parent() {
     901    public function test_is_single_with_parent() {
    902902        // Use custom hierarchical post type.
    903903        $post_type = 'test_hierarchical';
     
    10061006     * @ticket 38225
    10071007     */
    1008     function test_is_single_with_attachment() {
     1008    public function test_is_single_with_attachment() {
    10091009        $post_id = self::factory()->post->create();
    10101010
     
    10261026    }
    10271027
    1028     function test_is_page() {
     1028    public function test_is_page() {
    10291029        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    10301030        $this->go_to( "/?page_id=$post_id" );
     
    10461046     * @ticket 16802
    10471047     */
    1048     function test_is_page_with_parent() {
     1048    public function test_is_page_with_parent() {
    10491049        $parent_id = self::factory()->post->create(
    10501050            array(
     
    10801080    }
    10811081
    1082     function test_is_attachment() {
     1082    public function test_is_attachment() {
    10831083        $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    10841084        $this->go_to( "/?attachment_id=$post_id" );
     
    12371237    }
    12381238
    1239     function test_is_page_template() {
     1239    public function test_is_page_template() {
    12401240        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    12411241        update_post_meta( $post_id, '_wp_page_template', 'example.php' );
     
    12471247     * @ticket 31271
    12481248     */
    1249     function test_is_page_template_default() {
     1249    public function test_is_page_template_default() {
    12501250        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    12511251        $this->go_to( "/?page_id=$post_id" );
     
    12571257     * @ticket 31271
    12581258     */
    1259     function test_is_page_template_array() {
     1259    public function test_is_page_template_array() {
    12601260        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    12611261        update_post_meta( $post_id, '_wp_page_template', 'example.php' );
     
    12681268     * @ticket 18375
    12691269     */
    1270     function test_is_page_template_other_post_type() {
     1270    public function test_is_page_template_other_post_type() {
    12711271        $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
    12721272        update_post_meta( $post_id, '_wp_page_template', 'example.php' );
     
    12791279     * @ticket 39211
    12801280     */
    1281     function test_is_page_template_not_singular() {
     1281    public function test_is_page_template_not_singular() {
    12821282        global $wpdb;
    12831283
Note: See TracChangeset for help on using the changeset viewer.