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/theme/customHeader.php

    r47198 r48937  
    6363        $image = get_header_image();
    6464        $this->assertTrue( has_header_image() );
    65         $this->assertEquals( $default, $image );
     65        $this->assertSame( $default, $image );
    6666    }
    6767
     
    7373        set_theme_mod( 'header_image', $custom );
    7474        $image = get_header_image();
    75         $this->assertEquals( $custom, $image );
     75        $this->assertSame( $custom, $image );
    7676        $this->assertTrue( has_header_image() );
    7777
     
    130130        $this->_set_customize_previewing( true );
    131131        $html = get_custom_header_markup();
    132         $this->assertEquals( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html );
     132        $this->assertSame( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html );
    133133    }
    134134
     
    148148        set_theme_mod( 'header_video', self::$header_video_id );
    149149        $this->assertTrue( has_header_video() );
    150         $this->assertEquals( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() );
     150        $this->assertSame( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() );
    151151    }
    152152
     
    158158        set_theme_mod( 'external_header_video', $external );
    159159        $this->assertTrue( has_header_video() );
    160         $this->assertEquals( $external, get_header_video_url() );
     160        $this->assertSame( $external, get_header_video_url() );
    161161    }
    162162
     
    167167        set_theme_mod( 'header_video', self::$header_video_id );
    168168        set_theme_mod( 'external_header_video', $external );
    169         $this->assertEquals( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() );
     169        $this->assertSame( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() );
    170170    }
    171171
     
    183183        $this->assertTrue( has_header_video() );
    184184        $this->assertTrue( has_custom_header() );
    185         $this->assertEquals( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html );
     185        $this->assertSame( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html );
    186186    }
    187187
Note: See TracChangeset for help on using the changeset viewer.