Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit 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.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/http/http.php

    r47122 r48937  
    1414    function test_make_absolute_url( $relative_url, $absolute_url, $expected ) {
    1515        $actual = WP_Http::make_absolute_url( $relative_url, $absolute_url );
    16         $this->assertEquals( $expected, $actual );
     16        $this->assertSame( $expected, $actual );
    1717    }
    1818
     
    7373    function test_wp_parse_url( $url, $expected ) {
    7474        $actual = wp_parse_url( $url );
    75         $this->assertEquals( $expected, $actual );
     75        $this->assertSame( $expected, $actual );
    7676    }
    7777
     
    184184    function test_wp_parse_url_with_default_component() {
    185185        $actual = wp_parse_url( self::FULL_TEST_URL, -1 );
    186         $this->assertEquals(
     186        $this->assertSame(
    187187            array(
    188188                'scheme'   => 'http',
     
    272272        get_status_header_desc( 200 );
    273273
    274         $this->assertEquals( array_keys( $wp_header_to_desc ), array_values( $constants ) );
     274        $this->assertSame( array_keys( $wp_header_to_desc ), array_values( $constants ) );
    275275
    276276    }
Note: See TracChangeset for help on using the changeset viewer.