Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (4 years 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/comment/query.php

    r51331 r51367  
    12921292
    12931293        $comments = get_comments( array( 'post_id' => $post_id ) );
    1294         $this->assertSame( $limit, count( $comments ) );
     1294        $this->assertCount( $limit, $comments );
    12951295        foreach ( $comments as $comment ) {
    12961296            $this->assertEquals( $post_id, $comment->comment_post_ID );
     
    13011301
    13021302        $comments = get_comments( array( 'post_id' => $post_id2 ) );
    1303         $this->assertSame( $limit, count( $comments ) );
     1303        $this->assertCount( $limit, $comments );
    13041304        foreach ( $comments as $comment ) {
    13051305            $this->assertEquals( $post_id2, $comment->comment_post_ID );
     
    13101310
    13111311        $comments = get_comments( array( 'post_id' => $post_id3 ) );
    1312         $this->assertSame( $limit, count( $comments ) );
     1312        $this->assertCount( $limit, $comments );
    13131313        foreach ( $comments as $comment ) {
    13141314            $this->assertEquals( $post_id3, $comment->comment_post_ID );
     
    13211321            )
    13221322        );
    1323         $this->assertSame( $limit, count( $comments ) );
     1323        $this->assertCount( $limit, $comments );
    13241324        foreach ( $comments as $comment ) {
    13251325            $this->assertEquals( $post_id3, $comment->comment_post_ID );
     
    13321332            )
    13331333        );
    1334         $this->assertSame( 0, count( $comments ) );
     1334        $this->assertCount( 0, $comments );
    13351335
    13361336        self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) );
    13371337        $comments = get_comments( array( 'post_id' => $post_id3 ) );
    1338         $this->assertSame( $limit * 2, count( $comments ) );
     1338        $this->assertCount( $limit * 2, $comments );
    13391339        foreach ( $comments as $comment ) {
    13401340            $this->assertEquals( $post_id3, $comment->comment_post_ID );
     
    13631363            )
    13641364        );
    1365         $this->assertSame( 2, count( $comments ) );
     1365        $this->assertCount( 2, $comments );
    13661366        $this->assertEquals( $comment_id2, $comments[0]->comment_ID );
    13671367        $this->assertEquals( $comment_id, $comments[1]->comment_ID );
     
    13731373            )
    13741374        );
    1375         $this->assertSame( 2, count( $comments ) );
     1375        $this->assertCount( 2, $comments );
    13761376        $this->assertEquals( $comment_id2, $comments[0]->comment_ID );
    13771377        $this->assertEquals( $comment_id, $comments[1]->comment_ID );
     
    13841384            )
    13851385        );
    1386         $this->assertSame( 2, count( $comments ) );
     1386        $this->assertCount( 2, $comments );
    13871387        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
    13881388        $this->assertEquals( $comment_id2, $comments[1]->comment_ID );
     
    13951395            )
    13961396        );
    1397         $this->assertSame( 2, count( $comments ) );
     1397        $this->assertCount( 2, $comments );
    13981398        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
    13991399        $this->assertEquals( $comment_id2, $comments[1]->comment_ID );
     
    14231423            )
    14241424        );
    1425         $this->assertSame( 1, count( $comments ) );
     1425        $this->assertCount( 1, $comments );
    14261426
    14271427        $comments = get_comments(
     
    14311431            )
    14321432        );
    1433         $this->assertSame( 1, count( $comments ) );
     1433        $this->assertCount( 1, $comments );
    14341434    }
    14351435
Note: See TracChangeset for help on using the changeset viewer.