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/Smilies.php

    r47122 r48937  
    5555        smilies_init();
    5656
    57         $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) );
    58 
    59         // Standard smilies, use_smilies: OFF.
    60         update_option( 'use_smilies', 0 );
    61 
    62         $this->assertEquals( $in_txt, convert_smilies( $in_txt ) );
     57        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     58
     59        // Standard smilies, use_smilies: OFF.
     60        update_option( 'use_smilies', 0 );
     61
     62        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    6363    }
    6464
     
    113113        smilies_init();
    114114
    115         $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) );
    116 
    117         // Standard smilies, use_smilies: OFF.
    118         update_option( 'use_smilies', 0 );
    119 
    120         $this->assertEquals( $in_txt, convert_smilies( $in_txt ) );
     115        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     116
     117        // Standard smilies, use_smilies: OFF.
     118        update_option( 'use_smilies', 0 );
     119
     120        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    121121
    122122        $wpsmiliestrans = $trans_orig; // Reset original translations array.
     
    154154        smilies_init();
    155155
    156         $this->assertEquals( $exp_str, convert_smilies( $in_str ) );
     156        $this->assertSame( $exp_str, convert_smilies( $in_str ) );
    157157
    158158        // Standard smilies, use_smilies: OFF.
     
    206206        smilies_init();
    207207
    208         $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) );
     208        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
    209209
    210210        // Custom smilies, use_smilies: OFF.
    211211        update_option( 'use_smilies', 0 );
    212212
    213         $this->assertEquals( $in_txt, convert_smilies( $in_txt ) );
     213        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    214214    }
    215215
     
    261261        smilies_init();
    262262
    263         $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) );
    264 
    265         // Standard smilies, use_smilies: OFF.
    266         update_option( 'use_smilies', 0 );
    267 
    268         $this->assertEquals( $in_txt, convert_smilies( $in_txt ) );
     263        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     264
     265        // Standard smilies, use_smilies: OFF.
     266        update_option( 'use_smilies', 0 );
     267
     268        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    269269
    270270        $wpsmiliestrans = $orig_trans; // Reset original translations array.
     
    306306        smilies_init();
    307307
    308         $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) );
     308        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
    309309
    310310        // Standard smilies, use_smilies: OFF.
     
    324324        $txt = ':oops: I did it again';
    325325
    326         $this->assertEquals( $txt, convert_smilies( $txt ) );
     326        $this->assertSame( $txt, convert_smilies( $txt ) );
    327327    }
    328328
     
    340340        $expected_txt = 'You played with my \xe2\x9d\xa4';
    341341
    342         $this->assertEquals( $expected_txt, convert_smilies( $txt ) );
     342        $this->assertSame( $expected_txt, convert_smilies( $txt ) );
    343343    }
    344344
Note: See TracChangeset for help on using the changeset viewer.