Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/query.php

    r53942 r55562  
    713713    }
    714714
    715     public function set_found_posts_provider() {
     715    /**
     716     * @ticket 42860
     717     *
     718     * @dataProvider data_set_found_posts_not_posts_as_an_array
     719     */
     720    public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
     721        $q = new WP_Query(
     722            array(
     723                'post_type'      => 'wptests_pt',
     724                'posts_per_page' => 1,
     725            )
     726        );
     727
     728        $q->posts = $posts;
     729
     730        $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' );
     731        $methd->setAccessible( true );
     732        $methd->invoke( $q, array( 'no_found_rows' => false ), array() );
     733
     734        $this->assertSame( $expected, $q->found_posts );
     735    }
     736
     737    public function data_set_found_posts_not_posts_as_an_array() {
    716738        // Count return 0 for null, but 1 for other data you may not expect.
    717739        return array(
     
    724746
    725747    /**
    726      * @ticket 42860
    727      *
    728      * @dataProvider set_found_posts_provider
    729      */
    730     public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
    731         $q = new WP_Query(
    732             array(
    733                 'post_type'      => 'wptests_pt',
    734                 'posts_per_page' => 1,
    735             )
    736         );
    737 
    738         $q->posts = $posts;
    739 
    740         $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' );
    741         $methd->setAccessible( true );
    742         $methd->invoke( $q, array( 'no_found_rows' => false ), array() );
    743 
    744         $this->assertSame( $expected, $q->found_posts );
    745     }
    746 
    747     /**
    748748     * @ticket 42469
    749749     */
Note: See TracChangeset for help on using the changeset viewer.