WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertSame( [number], count( ... ) ) with assertCount() to use native PHPUnit functionality.

Follow-up to [51335], [51337].

See #53363.

File:
1 edited

Legend:

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

    r48939 r51367  
    697697        );
    698698
    699         $this->assertSame( 0, count( $query->posts ) );
     699        $this->assertCount( 0, $query->posts );
    700700    }
    701701
     
    15351535
    15361536        $query = new WP_Query( $args );
    1537         $this->assertSame( 2, count( $query->posts ) );
     1537        $this->assertCount( 2, $query->posts );
    15381538        foreach ( $query->posts as $post ) {
    15391539            $this->assertInstanceOf( 'WP_Post', $post );
     
    15511551
    15521552        $query = new WP_Query( $args );
    1553         $this->assertSame( 3, count( $query->posts ) );
     1553        $this->assertCount( 3, $query->posts );
    15541554        foreach ( $query->posts as $post ) {
    15551555            $this->assertInstanceOf( 'WP_Post', $post );
     
    15831583        );
    15841584
    1585         $this->assertSame( 2, count( $posts ) );
     1585        $this->assertCount( 2, $posts );
    15861586        $posts = wp_list_pluck( $posts, 'ID' );
    15871587        $this->assertSameSets( array( $post_id, $post_id3 ), $posts );
     
    15951595        );
    15961596
    1597         $this->assertSame( 2, count( $posts ) );
     1597        $this->assertCount( 2, $posts );
    15981598        foreach ( $posts as $post ) {
    15991599            $this->assertInstanceOf( 'WP_Post', $post );
     
    16261626
    16271627        $posts = get_posts( $args );
    1628         $this->assertSame( 2, count( $posts ) );
     1628        $this->assertCount( 2, $posts );
    16291629        foreach ( $posts as $post ) {
    16301630            $this->assertInstanceOf( 'WP_Post', $post );
     
    16601660            )
    16611661        );
    1662         $this->assertSame( 1, count( $q->posts ) );
     1662        $this->assertCount( 1, $q->posts );
    16631663        foreach ( $q->posts as $post ) {
    16641664            $this->assertInstanceOf( 'WP_Post', $post );
     
    16731673            )
    16741674        );
    1675         $this->assertSame( 2, count( $posts ) );
     1675        $this->assertCount( 2, $posts );
    16761676        foreach ( $posts as $post ) {
    16771677            $this->assertInstanceOf( 'WP_Post', $post );
     
    16871687            )
    16881688        );
    1689         $this->assertSame( 2, count( $posts ) );
     1689        $this->assertCount( 2, $posts );
    16901690        foreach ( $posts as $post ) {
    16911691            $this->assertInstanceOf( 'WP_Post', $post );
     
    16961696
    16971697        $posts = get_posts( array( 'meta_value' => 0 ) );
    1698         $this->assertSame( 5, count( $posts ) );
     1698        $this->assertCount( 5, $posts );
    16991699        foreach ( $posts as $post ) {
    17001700            $this->assertInstanceOf( 'WP_Post', $post );
     
    17051705
    17061706        $posts = get_posts( array( 'meta_value' => '0' ) );
    1707         $this->assertSame( 5, count( $posts ) );
     1707        $this->assertCount( 5,  $posts );
    17081708        foreach ( $posts as $post ) {
    17091709            $this->assertInstanceOf( 'WP_Post', $post );
Note: See TracChangeset for help on using the changeset viewer.