Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (5 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/rest-api/rest-pages-controller.php

    r50463 r51367  
    110110        $response = rest_get_server()->dispatch( $request );
    111111        $data     = $response->get_data();
    112         $this->assertSame( 1, count( $data ) );
     112        $this->assertCount( 1, $data );
    113113        $this->assertSame( $id1, $data[0]['id'] );
    114114    }
     
    133133        $response = rest_get_server()->dispatch( $request );
    134134        $data     = $response->get_data();
    135         $this->assertSame( 2, count( $data ) );
     135        $this->assertCount( 2, $data );
    136136
    137137        // Filter to parent.
     
    139139        $response = rest_get_server()->dispatch( $request );
    140140        $data     = $response->get_data();
    141         $this->assertSame( 1, count( $data ) );
     141        $this->assertCount( 1, $data );
    142142        $this->assertSame( $id2, $data[0]['id'] );
    143143
     
    180180        $response = rest_get_server()->dispatch( $request );
    181181        $data     = $response->get_data();
    182         $this->assertSame( 4, count( $data ) );
     182        $this->assertCount( 4, $data );
    183183
    184184        // Filter to parents.
     
    186186        $response = rest_get_server()->dispatch( $request );
    187187        $data     = $response->get_data();
    188         $this->assertSame( 2, count( $data ) );
     188        $this->assertCount( 2, $data );
    189189        $this->assertSameSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) );
    190190    }
     
    209209        $response = rest_get_server()->dispatch( $request );
    210210        $data     = $response->get_data();
    211         $this->assertSame( 2, count( $data ) );
     211        $this->assertCount( 2, $data );
    212212
    213213        // Filter to parent.
     
    215215        $response = rest_get_server()->dispatch( $request );
    216216        $data     = $response->get_data();
    217         $this->assertSame( 1, count( $data ) );
     217        $this->assertCount( 1, $data );
    218218        $this->assertSame( $id1, $data[0]['id'] );
    219219
     
    559559
    560560        $all_data = $response->get_data();
    561         $this->assertSame( 4, count( $all_data ) );
     561        $this->assertCount( 4, $all_data );
    562562        foreach ( $all_data as $post ) {
    563563            $this->assertSame( 'page', $post['type'] );
     
    738738        $data       = $response->get_data();
    739739        $properties = $data['schema']['properties'];
    740         $this->assertSame( 24, count( $properties ) );
     740        $this->assertCount( 24, $properties );
    741741        $this->assertArrayHasKey( 'author', $properties );
    742742        $this->assertArrayHasKey( 'comment_status', $properties );
Note: See TracChangeset for help on using the changeset viewer.