Make WordPress Core

Changeset 51225


Ignore:
Timestamp:
06/24/2021 06:51:54 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in _wp_to_kebab_case() 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.

Follow-up to [51079], [51198].

See #52482, #52625, #53397.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/wpToKebabCase.php

    r51198 r51225  
    1212
    1313    public function test_wp_to_kebab_case() {
    14         $this->assertEquals( 'white', _wp_to_kebab_case( 'white' ) );
    15         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white+black' ) );
    16         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white:black' ) );
    17         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white*black' ) );
    18         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white.black' ) );
    19         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white black' ) );
    20         $this->assertEquals( 'white-black', _wp_to_kebab_case( 'white   black' ) );
    21         $this->assertEquals( 'white-to-black', _wp_to_kebab_case( 'white-to-black' ) );
    22         $this->assertEquals( 'white-2-white', _wp_to_kebab_case( 'white2white' ) );
    23         $this->assertEquals( 'white-2nd', _wp_to_kebab_case( 'white2nd' ) );
    24         $this->assertEquals( 'white-2-ndcolor', _wp_to_kebab_case( 'white2ndcolor' ) );
    25         $this->assertEquals( 'white-2nd-color', _wp_to_kebab_case( 'white2ndColor' ) );
    26         $this->assertEquals( 'white-2nd-color', _wp_to_kebab_case( 'white2nd_color' ) );
    27         $this->assertEquals( 'white-23-color', _wp_to_kebab_case( 'white23color' ) );
    28         $this->assertEquals( 'white-23', _wp_to_kebab_case( 'white23' ) );
    29         $this->assertEquals( '23-color', _wp_to_kebab_case( '23color' ) );
    30         $this->assertEquals( 'white-4th', _wp_to_kebab_case( 'white4th' ) );
    31         $this->assertEquals( 'font-2-xl', _wp_to_kebab_case( 'font2xl' ) );
    32         $this->assertEquals( 'white-to-white', _wp_to_kebab_case( 'whiteToWhite' ) );
    33         $this->assertEquals( 'white-t-owhite', _wp_to_kebab_case( 'whiteTOwhite' ) );
    34         $this->assertEquals( 'whit-eto-white', _wp_to_kebab_case( 'WHITEtoWHITE' ) );
    35         $this->assertEquals( '42', _wp_to_kebab_case( 42 ) );
    36         $this->assertEquals( 'ive-done', _wp_to_kebab_case( "i've done" ) );
    37         $this->assertEquals( 'ffffff', _wp_to_kebab_case( '#ffffff' ) );
    38         $this->assertEquals( 'ffffff', _wp_to_kebab_case( '$ffffff' ) );
     14        $this->assertSame( 'white', _wp_to_kebab_case( 'white' ) );
     15        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white+black' ) );
     16        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white:black' ) );
     17        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white*black' ) );
     18        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white.black' ) );
     19        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white black' ) );
     20        $this->assertSame( 'white-black', _wp_to_kebab_case( 'white black' ) );
     21        $this->assertSame( 'white-to-black', _wp_to_kebab_case( 'white-to-black' ) );
     22        $this->assertSame( 'white-2-white', _wp_to_kebab_case( 'white2white' ) );
     23        $this->assertSame( 'white-2nd', _wp_to_kebab_case( 'white2nd' ) );
     24        $this->assertSame( 'white-2-ndcolor', _wp_to_kebab_case( 'white2ndcolor' ) );
     25        $this->assertSame( 'white-2nd-color', _wp_to_kebab_case( 'white2ndColor' ) );
     26        $this->assertSame( 'white-2nd-color', _wp_to_kebab_case( 'white2nd_color' ) );
     27        $this->assertSame( 'white-23-color', _wp_to_kebab_case( 'white23color' ) );
     28        $this->assertSame( 'white-23', _wp_to_kebab_case( 'white23' ) );
     29        $this->assertSame( '23-color', _wp_to_kebab_case( '23color' ) );
     30        $this->assertSame( 'white-4th', _wp_to_kebab_case( 'white4th' ) );
     31        $this->assertSame( 'font-2-xl', _wp_to_kebab_case( 'font2xl' ) );
     32        $this->assertSame( 'white-to-white', _wp_to_kebab_case( 'whiteToWhite' ) );
     33        $this->assertSame( 'white-t-owhite', _wp_to_kebab_case( 'whiteTOwhite' ) );
     34        $this->assertSame( 'whit-eto-white', _wp_to_kebab_case( 'WHITEtoWHITE' ) );
     35        $this->assertSame( '42', _wp_to_kebab_case( 42 ) );
     36        $this->assertSame( 'ive-done', _wp_to_kebab_case( "i've done" ) );
     37        $this->assertSame( 'ffffff', _wp_to_kebab_case( '#ffffff' ) );
     38        $this->assertSame( 'ffffff', _wp_to_kebab_case( '$ffffff' ) );
    3939    }
    4040}
Note: See TracChangeset for help on using the changeset viewer.