Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (3 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/xmlrpc/wp/getTerms.php

    r51331 r51367  
    7878        $this->assertNotIXRError( $results );
    7979
    80         $this->assertSame( $num_terms, count( $results ) );
     80        $this->assertCount( $num_terms, $results );
    8181        foreach ( $results as $term ) {
    8282            $this->assertSame( $tax_name, $term['taxonomy'] );
     
    8787        $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    8888        $this->assertNotIXRError( $results );
    89         $this->assertSame( 5, count( $results2 ) );
     89        $this->assertCount( 5, $results2 );
    9090        $this->assertSame( $results[1]['term_id'], $results2[1]['term_id'] ); // Check one of the terms.
    9191
     
    9393        $results3         = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    9494        $this->assertNotIXRError( $results3 );
    95         $this->assertSame( $num_terms - 10, count( $results3 ) );
     95        $this->assertCount( $num_terms - 10, $results3 );
    9696        $this->assertSame( $results[11]['term_id'], $results3[1]['term_id'] );
    9797
     
    100100        $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    101101        $this->assertNotIXRError( $results4 );
    102         $this->assertSame( 0, count( $results4 ) );
     102        $this->assertCount( 0, $results4 );
    103103
    104104        unset( $GLOBALS['wp_taxonomies'][ $tax_name ] );
     
    120120        $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    121121        $this->assertNotIXRError( $results );
    122         $this->assertNotEquals( 0, count( $results ) );
     122        $this->assertNotCount( 0, $results );
    123123
    124124        foreach ( $results as $term ) {
     
    141141        $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    142142        $this->assertNotIXRError( $results );
    143         $this->assertSame( 1, count( $results ) );
     143        $this->assertCount( 1, $results );
    144144        $this->assertSame( $name, $results[0]['name'] );
    145145        $this->assertEquals( $name_id, $results[0]['term_id'] );
     
    149149        $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    150150        $this->assertNotIXRError( $results2 );
    151         $this->assertSame( 1, count( $results2 ) );
     151        $this->assertCount( 1, $results2 );
    152152        $this->assertSame( $name, $results2[0]['name'] );
    153153        $this->assertEquals( $name_id, $results2[0]['term_id'] );
Note: See TracChangeset for help on using the changeset viewer.