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/option/slashes.php

    r47122 r48937  
    2929        add_option( 'slash_test_4', $this->slash_4 );
    3030
    31         $this->assertEquals( $this->slash_1, get_option( 'slash_test_1' ) );
    32         $this->assertEquals( $this->slash_2, get_option( 'slash_test_2' ) );
    33         $this->assertEquals( $this->slash_3, get_option( 'slash_test_3' ) );
    34         $this->assertEquals( $this->slash_4, get_option( 'slash_test_4' ) );
     31        $this->assertSame( $this->slash_1, get_option( 'slash_test_1' ) );
     32        $this->assertSame( $this->slash_2, get_option( 'slash_test_2' ) );
     33        $this->assertSame( $this->slash_3, get_option( 'slash_test_3' ) );
     34        $this->assertSame( $this->slash_4, get_option( 'slash_test_4' ) );
    3535    }
    3636
     
    4242
    4343        update_option( 'slash_test_5', $this->slash_1 );
    44         $this->assertEquals( $this->slash_1, get_option( 'slash_test_5' ) );
     44        $this->assertSame( $this->slash_1, get_option( 'slash_test_5' ) );
    4545
    4646        update_option( 'slash_test_5', $this->slash_2 );
    47         $this->assertEquals( $this->slash_2, get_option( 'slash_test_5' ) );
     47        $this->assertSame( $this->slash_2, get_option( 'slash_test_5' ) );
    4848
    4949        update_option( 'slash_test_5', $this->slash_3 );
    50         $this->assertEquals( $this->slash_3, get_option( 'slash_test_5' ) );
     50        $this->assertSame( $this->slash_3, get_option( 'slash_test_5' ) );
    5151
    5252        update_option( 'slash_test_5', $this->slash_4 );
    53         $this->assertEquals( $this->slash_4, get_option( 'slash_test_5' ) );
     53        $this->assertSame( $this->slash_4, get_option( 'slash_test_5' ) );
    5454    }
    5555}
Note: See TracChangeset for help on using the changeset viewer.