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

    r46586 r48937  
    77    function test_esc_attr_quotes() {
    88        $attr = '"double quotes"';
    9         $this->assertEquals( '"double quotes"', esc_attr( $attr ) );
     9        $this->assertSame( '"double quotes"', esc_attr( $attr ) );
    1010
    1111        $attr = "'single quotes'";
    12         $this->assertEquals( ''single quotes'', esc_attr( $attr ) );
     12        $this->assertSame( ''single quotes'', esc_attr( $attr ) );
    1313
    1414        $attr = "'mixed' " . '"quotes"';
    15         $this->assertEquals( ''mixed' "quotes"', esc_attr( $attr ) );
     15        $this->assertSame( ''mixed' "quotes"', esc_attr( $attr ) );
    1616
    1717        // Handles double encoding?
    1818        $attr = '"double quotes"';
    19         $this->assertEquals( '"double quotes"', esc_attr( esc_attr( $attr ) ) );
     19        $this->assertSame( '"double quotes"', esc_attr( esc_attr( $attr ) ) );
    2020
    2121        $attr = "'single quotes'";
    22         $this->assertEquals( ''single quotes'', esc_attr( esc_attr( $attr ) ) );
     22        $this->assertSame( ''single quotes'', esc_attr( esc_attr( $attr ) ) );
    2323
    2424        $attr = "'mixed' " . '"quotes"';
    25         $this->assertEquals( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) );
     25        $this->assertSame( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) );
    2626    }
    2727
    2828    function test_esc_attr_amp() {
    2929        $out = esc_attr( 'foo & bar &baz;  ' );
    30         $this->assertEquals( 'foo & bar &baz;  ', $out );
     30        $this->assertSame( 'foo & bar &baz;  ', $out );
    3131    }
    3232}
Note: See TracChangeset for help on using the changeset viewer.