Make WordPress Core


Ignore:
Timestamp:
03/15/2025 11:26:50 PM (12 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-global-styles-revisions-controller.php

    r59979 r59985  
    959959        $request->set_param( 'per_page', 1 );
    960960        $response = rest_get_server()->dispatch( $request );
    961         $this->assertEquals( 200, $response->get_status() );
     961        $this->assertSame( 200, $response->get_status() );
    962962        $data = $response->get_data();
    963963        $this->assertCount( 1, $data );
    964         $this->assertEquals( 3, $response->get_headers()['X-WP-Total'] );
    965         $this->assertEquals( 3, $response->get_headers()['X-WP-TotalPages'] );
     964        $this->assertSame( 3, $response->get_headers()['X-WP-Total'] );
     965        $this->assertSame( 3, $response->get_headers()['X-WP-TotalPages'] );
    966966
    967967        // Test paged.
     
    970970        $request->set_param( 'per_page', 2 );
    971971        $response = rest_get_server()->dispatch( $request );
    972         $this->assertEquals( 200, $response->get_status() );
     972        $this->assertSame( 200, $response->get_status() );
    973973        $data = $response->get_data();
    974974        $this->assertCount( 1, $data );
    975         $this->assertEquals( 3, $response->get_headers()['X-WP-Total'] );
    976         $this->assertEquals( 2, $response->get_headers()['X-WP-TotalPages'] );
     975        $this->assertSame( 3, $response->get_headers()['X-WP-Total'] );
     976        $this->assertSame( 2, $response->get_headers()['X-WP-TotalPages'] );
    977977
    978978        // Test out of bounds.
Note: See TracChangeset for help on using the changeset viewer.