WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months 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/general/template.php

    r48924 r48937  
    3939
    4040        $this->_set_site_icon();
    41         $this->assertEquals( $this->site_icon_url, get_site_icon_url() );
     41        $this->assertSame( $this->site_icon_url, get_site_icon_url() );
    4242
    4343        $this->_remove_site_icon();
     
    324324
    325325        $expected_custom_logo = '<a href="' . $home_url . '" class="custom-logo-link" rel="home">' . $image . '</a>';
    326         $this->assertEquals( $expected_custom_logo, get_custom_logo( $blog_id ) );
     326        $this->assertSame( $expected_custom_logo, get_custom_logo( $blog_id ) );
    327327    }
    328328
     
    555555     */
    556556    function test_selected_and_checked_with_equal_values( $selected, $current ) {
    557         $this->assertEquals( " selected='selected'", selected( $selected, $current, false ) );
    558         $this->assertEquals( " checked='checked'", checked( $selected, $current, false ) );
     557        $this->assertSame( " selected='selected'", selected( $selected, $current, false ) );
     558        $this->assertSame( " checked='checked'", checked( $selected, $current, false ) );
    559559    }
    560560
     
    579579     */
    580580    function test_selected_and_checked_with_non_equal_values( $selected, $current ) {
    581         $this->assertEquals( '', selected( $selected, $current, false ) );
    582         $this->assertEquals( '', checked( $selected, $current, false ) );
     581        $this->assertSame( '', selected( $selected, $current, false ) );
     582        $this->assertSame( '', checked( $selected, $current, false ) );
    583583    }
    584584
Note: See TracChangeset for help on using the changeset viewer.