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/formatting/Slashit.php

    r46586 r48937  
    66class Tests_Formatting_Slashit extends WP_UnitTestCase {
    77    function test_backslashes_middle_numbers() {
    8         $this->assertEquals( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) );
     8        $this->assertSame( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) );
    99    }
    1010
    1111    function test_backslashes_alphas() {
    12         $this->assertEquals( "\\a943\\b\\c", backslashit( 'a943bc' ) );
     12        $this->assertSame( "\\a943\\b\\c", backslashit( 'a943bc' ) );
    1313    }
    1414
    1515    function test_double_backslashes_leading_numbers() {
    16         $this->assertEquals( '\\\\95', backslashit( '95' ) );
     16        $this->assertSame( '\\\\95', backslashit( '95' ) );
    1717    }
    1818
    1919    function test_removes_trailing_slashes() {
    20         $this->assertEquals( 'a', untrailingslashit( 'a/' ) );
    21         $this->assertEquals( 'a', untrailingslashit( 'a////' ) );
     20        $this->assertSame( 'a', untrailingslashit( 'a/' ) );
     21        $this->assertSame( 'a', untrailingslashit( 'a////' ) );
    2222    }
    2323
     
    2626     */
    2727    function test_removes_trailing_backslashes() {
    28         $this->assertEquals( 'a', untrailingslashit( 'a\\' ) );
    29         $this->assertEquals( 'a', untrailingslashit( 'a\\\\\\\\' ) );
     28        $this->assertSame( 'a', untrailingslashit( 'a\\' ) );
     29        $this->assertSame( 'a', untrailingslashit( 'a\\\\\\\\' ) );
    3030    }
    3131
     
    3434     */
    3535    function test_removes_trailing_mixed_slashes() {
    36         $this->assertEquals( 'a', untrailingslashit( 'a/\\' ) );
    37         $this->assertEquals( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) );
     36        $this->assertSame( 'a', untrailingslashit( 'a/\\' ) );
     37        $this->assertSame( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) );
    3838    }
    3939
    4040    function test_adds_trailing_slash() {
    41         $this->assertEquals( 'a/', trailingslashit( 'a' ) );
     41        $this->assertSame( 'a/', trailingslashit( 'a' ) );
    4242    }
    4343
    4444    function test_does_not_add_trailing_slash_if_one_exists() {
    45         $this->assertEquals( 'a/', trailingslashit( 'a/' ) );
     45        $this->assertSame( 'a/', trailingslashit( 'a/' ) );
    4646    }
    4747
     
    5050     */
    5151    function test_converts_trailing_backslash_to_slash_if_one_exists() {
    52         $this->assertEquals( 'a/', trailingslashit( 'a\\' ) );
     52        $this->assertSame( 'a/', trailingslashit( 'a\\' ) );
    5353    }
    5454}
Note: See TracChangeset for help on using the changeset viewer.