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

    r47122 r48937  
    77    function test_js_escape_simple() {
    88        $out = esc_js( 'foo bar baz();' );
    9         $this->assertEquals( 'foo bar baz();', $out );
     9        $this->assertSame( 'foo bar baz();', $out );
    1010    }
    1111
     
    1313        $out = esc_js( 'foo "bar" \'baz\'' );
    1414        // Does it make any sense to change " into "?  Why not \"?
    15         $this->assertEquals( "foo "bar" \'baz\'", $out );
     15        $this->assertSame( "foo "bar" \'baz\'", $out );
    1616    }
    1717
     
    2020        $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' );
    2121        // \t becomes t - bug?
    22         $this->assertEquals( 'foo t bar ' . $bs . $bs . ' baz', $out );
     22        $this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out );
    2323    }
    2424
    2525    function test_js_escape_amp() {
    2626        $out = esc_js( 'foo & bar &baz;  ' );
    27         $this->assertEquals( 'foo & bar &baz;  ', $out );
     27        $this->assertSame( 'foo & bar &baz;  ', $out );
    2828    }
    2929
    3030    function test_js_escape_quote_entity() {
    3131        $out = esc_js( 'foo ' bar ' baz &' );
    32         $this->assertEquals( "foo \\' bar \\' baz &", $out );
     32        $this->assertSame( "foo \\' bar \\' baz &", $out );
    3333    }
    3434
Note: See TracChangeset for help on using the changeset viewer.