Make WordPress Core


Ignore:
Timestamp:
03/15/2025 11:26:50 PM (10 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in some newly introduced tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Follow-up to [59630].

See #62278.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r59979 r59985  
    59455945        $request->set_param( 'per_page', 1 );
    59465946        $response = rest_get_server()->dispatch( $request );
    5947         $this->assertEquals( 200, $response->get_status() );
     5947        $this->assertSame( 200, $response->get_status() );
    59485948        $data = $response->get_data();
    59495949        $this->assertCount( 1, $data );
    5950         $this->assertEquals( 30, $response->get_headers()['X-WP-Total'] );
    5951         $this->assertEquals( 30, $response->get_headers()['X-WP-TotalPages'] );
     5950        $this->assertSame( 30, $response->get_headers()['X-WP-Total'] );
     5951        $this->assertSame( 30, $response->get_headers()['X-WP-TotalPages'] );
    59525952
    59535953        // Test paged.
     
    59565956        $request->set_param( 'per_page', 2 );
    59575957        $response = rest_get_server()->dispatch( $request );
    5958         $this->assertEquals( 200, $response->get_status() );
     5958        $this->assertSame( 200, $response->get_status() );
    59595959        $data = $response->get_data();
    59605960        $this->assertCount( 2, $data );
    5961         $this->assertEquals( 30, $response->get_headers()['X-WP-Total'] );
    5962         $this->assertEquals( 15, $response->get_headers()['X-WP-TotalPages'] );
     5961        $this->assertSame( 30, $response->get_headers()['X-WP-Total'] );
     5962        $this->assertSame( 15, $response->get_headers()['X-WP-TotalPages'] );
    59635963
    59645964        // Test out of bounds.
Note: See TracChangeset for help on using the changeset viewer.