WordPress.org

Make WordPress Core


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

    r50463 r51367  
    201201        $response = rest_get_server()->dispatch( $request );
    202202        $data     = $response->get_data();
    203         $this->assertSame( 2, count( $data ) );
     203        $this->assertCount( 2, $data );
    204204        $this->assertSame( 'Season 5', $data[0]['name'] );
    205205        $this->assertSame( 'The Be Sharps', $data[1]['name'] );
     
    221221        $response = rest_get_server()->dispatch( $request );
    222222        $data     = $response->get_data();
    223         $this->assertSame( 2, count( $data ) );
     223        $this->assertCount( 2, $data );
    224224        $this->assertSame( $id1, $data[0]['id'] );
    225225
     
    228228        $response = rest_get_server()->dispatch( $request );
    229229        $data     = $response->get_data();
    230         $this->assertSame( 2, count( $data ) );
     230        $this->assertCount( 2, $data );
    231231        $this->assertSame( $id2, $data[0]['id'] );
    232232
     
    303303        $this->assertSame( 200, $response->get_status() );
    304304        $data = $response->get_data();
    305         $this->assertSame( 1, count( $data ) );
     305        $this->assertCount( 1, $data );
    306306        $this->assertSame( 'Zucchini', $data[0]['name'] );
    307307
     
    313313        $this->assertSame( 200, $response->get_status() );
    314314        $data = $response->get_data();
    315         $this->assertSame( 2, count( $data ) );
     315        $this->assertCount( 2, $data );
    316316        $this->assertSame( 'Apple', $data[0]['name'] );
    317317
     
    388388
    389389        $data = $response->get_data();
    390         $this->assertSame( 2, count( $data ) );
     390        $this->assertCount( 2, $data );
    391391        $this->assertSame( 'DC', $data[0]['name'] );
    392392
     
    475475
    476476        $data = $response->get_data();
    477         $this->assertSame( 2, count( $data ) );
     477        $this->assertCount( 2, $data );
    478478        $this->assertSame( 'Cape', $data[0]['name'] );
    479479    }
     
    492492        $this->assertSame( 200, $response->get_status() );
    493493        $data = $response->get_data();
    494         $this->assertSame( 1, count( $data ) );
     494        $this->assertCount( 1, $data );
    495495        $this->assertSame( 'Apple', $data[0]['name'] );
    496496
     
    500500        $this->assertSame( 200, $response->get_status() );
    501501        $data = $response->get_data();
    502         $this->assertSame( 0, count( $data ) );
     502        $this->assertCount( 0, $data );
    503503    }
    504504
     
    512512        $this->assertSame( 200, $response->get_status() );
    513513        $data = $response->get_data();
    514         $this->assertSame( 1, count( $data ) );
     514        $this->assertCount( 1, $data );
    515515        $this->assertSame( 'Apple', $data[0]['name'] );
    516516    }
     
    12251225        $data       = $response->get_data();
    12261226        $properties = $data['schema']['properties'];
    1227         $this->assertSame( 8, count( $properties ) );
     1227        $this->assertCount( 8, $properties );
    12281228        $this->assertArrayHasKey( 'id', $properties );
    12291229        $this->assertArrayHasKey( 'count', $properties );
Note: See TracChangeset for help on using the changeset viewer.