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/functions/canonicalCharset.php

    r47780 r48937  
    1010
    1111    public function test_utf_8_lower() {
    12         $this->assertEquals( 'UTF-8', _canonical_charset( 'utf-8' ) );
     12        $this->assertSame( 'UTF-8', _canonical_charset( 'utf-8' ) );
    1313    }
    1414
    1515    public function test_utf_8_upper() {
    16         $this->assertEquals( 'UTF-8', _canonical_charset( 'UTF-8' ) );
     16        $this->assertSame( 'UTF-8', _canonical_charset( 'UTF-8' ) );
    1717    }
    1818
    1919    public function test_utf_8_mixxed() {
    20         $this->assertEquals( 'UTF-8', _canonical_charset( 'Utf-8' ) );
     20        $this->assertSame( 'UTF-8', _canonical_charset( 'Utf-8' ) );
    2121    }
    2222
    2323    public function test_utf_8() {
    24         $this->assertEquals( 'UTF-8', _canonical_charset( 'UTF8' ) );
     24        $this->assertSame( 'UTF-8', _canonical_charset( 'UTF8' ) );
    2525    }
    2626
    2727    public function test_iso_lower() {
    28         $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'iso-8859-1' ) );
     28        $this->assertSame( 'ISO-8859-1', _canonical_charset( 'iso-8859-1' ) );
    2929    }
    3030
    3131    public function test_iso_upper() {
    32         $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO-8859-1' ) );
     32        $this->assertSame( 'ISO-8859-1', _canonical_charset( 'ISO-8859-1' ) );
    3333    }
    3434
    3535    public function test_iso_mixxed() {
    36         $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'Iso8859-1' ) );
     36        $this->assertSame( 'ISO-8859-1', _canonical_charset( 'Iso8859-1' ) );
    3737    }
    3838
    3939    public function test_iso() {
    40         $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO8859-1' ) );
     40        $this->assertSame( 'ISO-8859-1', _canonical_charset( 'ISO8859-1' ) );
    4141    }
    4242
    4343    public function test_random() {
    44         $this->assertEquals( 'random', _canonical_charset( 'random' ) );
     44        $this->assertSame( 'random', _canonical_charset( 'random' ) );
    4545    }
    4646
    4747    public function test_empty() {
    48         $this->assertEquals( '', _canonical_charset( '' ) );
     48        $this->assertSame( '', _canonical_charset( '' ) );
    4949    }
    5050
     
    5656
    5757        update_option( 'blog_charset', 'utf8' );
    58         $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
     58        $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) );
    5959
    6060        update_option( 'blog_charset', 'utf-8' );
    61         $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
     61        $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) );
    6262
    6363        update_option( 'blog_charset', 'UTF8' );
    64         $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
     64        $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) );
    6565
    6666        update_option( 'blog_charset', 'UTF-8' );
    67         $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
     67        $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) );
    6868
    6969        update_option( 'blog_charset', 'ISO-8859-1' );
    70         $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
     70        $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) );
    7171
    7272        update_option( 'blog_charset', 'ISO8859-1' );
    73         $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
     73        $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) );
    7474
    7575        update_option( 'blog_charset', 'iso8859-1' );
    76         $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
     76        $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) );
    7777
    7878        update_option( 'blog_charset', 'iso-8859-1' );
    79         $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
     79        $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) );
    8080
    8181        // Arbitrary strings are passed through.
    8282        update_option( 'blog_charset', 'foobarbaz' );
    83         $this->assertEquals( 'foobarbaz', get_option( 'blog_charset' ) );
     83        $this->assertSame( 'foobarbaz', get_option( 'blog_charset' ) );
    8484
    8585        update_option( 'blog_charset', $orig_blog_charset );
Note: See TracChangeset for help on using the changeset viewer.