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

    r51568 r52010  
    33class Tests_Query extends WP_UnitTestCase {
    44
    5     function set_up() {
     5    public function set_up() {
    66        parent::set_up();
    77
     
    1313     * @ticket 24785
    1414     */
    15     function test_nested_loop_reset_postdata() {
     15    public function test_nested_loop_reset_postdata() {
    1616        $post_id        = self::factory()->post->create();
    1717        $nested_post_id = self::factory()->post->create();
     
    3333     * @ticket 16471
    3434     */
    35     function test_default_query_var() {
     35    public function test_default_query_var() {
    3636        $query = new WP_Query;
    3737        $this->assertSame( '', $query->get( 'nonexistent' ) );
     
    4343     * @ticket 25380
    4444     */
    45     function test_pre_posts_per_page() {
     45    public function test_pre_posts_per_page() {
    4646        self::factory()->post->create_many( 10 );
    4747
     
    5353    }
    5454
    55     function filter_posts_per_page( &$query ) {
     55    public function filter_posts_per_page( &$query ) {
    5656        $query->set( 'posts_per_rss', 30 );
    5757    }
     
    6060     * @ticket 26627
    6161     */
    62     function test_tag_queried_object() {
     62    public function test_tag_queried_object() {
    6363        $slug = 'tag-slug-26627';
    6464        self::factory()->tag->create( array( 'slug' => $slug ) );
    6565        $tag = get_term_by( 'slug', $slug, 'post_tag' );
    6666
    67         add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
     67        add_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 );
    6868
    6969        $this->go_to( get_term_link( $tag ) );
     
    7676        $this->assertEquals( get_queried_object(), $tag );
    7777
    78         remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
    79     }
    80 
    81     function _tag_queried_object( &$query ) {
     78        remove_action( 'pre_get_posts', array( $this, 'tag_queried_object' ), 11 );
     79    }
     80
     81    public function tag_queried_object( &$query ) {
    8282        $tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' );
    8383        $this->assertTrue( $query->is_tag() );
Note: See TracChangeset for help on using the changeset viewer.