Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (3 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/option/themeMods.php

    r46586 r48937  
    77
    88    function test_theme_mod_default() {
    9         $this->assertEquals( '', get_theme_mod( 'non_existent' ) );
     9        $this->assertFalse( get_theme_mod( 'non_existent' ) );
    1010    }
    1111
    1212    function test_theme_mod_defined_default() {
    13         $this->assertEquals( 'default', get_theme_mod( 'non_existent', 'default' ) );
     13        $this->assertSame( 'default', get_theme_mod( 'non_existent', 'default' ) );
    1414    }
    1515
     
    1717        $expected = 'value';
    1818        set_theme_mod( 'test_name', $expected );
    19         $this->assertEquals( $expected, get_theme_mod( 'test_name' ) );
     19        $this->assertSame( $expected, get_theme_mod( 'test_name' ) );
    2020    }
    2121
     
    2424        $expected = 'updated_value';
    2525        set_theme_mod( 'test_update', $expected );
    26         $this->assertEquals( $expected, get_theme_mod( 'test_update' ) );
     26        $this->assertSame( $expected, get_theme_mod( 'test_update' ) );
    2727    }
    2828
     
    3030        set_theme_mod( 'test_remove', 'value' );
    3131        remove_theme_mod( 'test_remove' );
    32         $this->assertEquals( '', get_theme_mod( 'test_remove' ) );
     32        $this->assertFalse( get_theme_mod( 'test_remove' ) );
    3333    }
    3434
     
    3939     */
    4040    function test_theme_mod_default_value_with_percent_symbols( $default, $expected ) {
    41         $this->assertEquals( $expected, get_theme_mod( 'test_name', $default ) );
     41        $this->assertSame( $expected, get_theme_mod( 'test_name', $default ) );
    4242    }
    4343
Note: See TracChangeset for help on using the changeset viewer.