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

    r50463 r51367  
    8686            )
    8787        );
    88         $this->assertSame( 11, count( $posts ) );
     88        $this->assertCount( 11, $posts );
    8989
    9090        $post = $posts[0];
     
    9696        $this->assertSame( 0, $post->post_parent );
    9797        $cats = wp_get_post_categories( $post->ID );
    98         $this->assertSame( 27, count( $cats ) );
     98        $this->assertCount( 27, $cats );
    9999
    100100        $post = $posts[1];
     
    106106        $this->assertSame( 0, $post->post_parent );
    107107        $cats = wp_get_post_categories( $post->ID );
    108         $this->assertSame( 1, count( $cats ) );
     108        $this->assertCount( 1, $cats );
    109109        $this->assertTrue( has_post_format( 'aside', $post->ID ) );
    110110
     
    117117        $this->assertSame( 0, $post->post_parent );
    118118        $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
    119         $this->assertSame( 1, count( $cats ) );
     119        $this->assertCount( 1, $cats );
    120120        $this->assertSame( 'foo', $cats[0]->slug );
    121121
     
    128128        $this->assertSame( 0, $post->post_parent );
    129129        $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
    130         $this->assertSame( 1, count( $cats ) );
     130        $this->assertCount( 1, $cats );
    131131        $this->assertSame( 'foo-bar', $cats[0]->slug );
    132132
     
    139139        $this->assertSame( 0, $post->post_parent );
    140140        $cats = wp_get_post_categories( $post->ID );
    141         $this->assertSame( 1, count( $cats ) );
     141        $this->assertCount( 1, $cats );
    142142        $tags = wp_get_post_tags( $post->ID );
    143         $this->assertSame( 3, count( $tags ) );
     143        $this->assertCount( 3, $tags );
    144144        $this->assertSame( 'tag1', $tags[0]->slug );
    145145        $this->assertSame( 'tag2', $tags[1]->slug );
     
    199199        $this->assertSame( 0, $post->post_parent );
    200200        $cats = wp_get_post_categories( $post->ID );
    201         $this->assertSame( 1, count( $cats ) );
     201        $this->assertCount( 1, $cats );
    202202    }
    203203
Note: See TracChangeset for help on using the changeset viewer.