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

    r48576 r48937  
    1515    public function test_esc_xml_basics( $source, $expected ) {
    1616        $actual = esc_xml( $source );
    17         $this->assertEquals( $expected, $actual );
     17        $this->assertSame( $expected, $actual );
    1818    }
    1919
     
    5050        $expected = 'penn & teller & at&t';
    5151        $actual   = esc_xml( $source );
    52         $this->assertEquals( $expected, $actual );
     52        $this->assertSame( $expected, $actual );
    5353    }
    5454
     
    5757        $expected = 'this > that < that <randomhtml />';
    5858        $actual   = esc_xml( $source );
    59         $this->assertEquals( $expected, $actual );
     59        $this->assertSame( $expected, $actual );
    6060    }
    6161
     
    6464        $expected = 'this & is a … followed by › and more and a &nonexistent; entity';
    6565        $actual   = esc_xml( $source );
    66         $this->assertEquals( $expected, $actual );
     66        $this->assertSame( $expected, $actual );
    6767    }
    6868
     
    7272        $expected = '& £ " &';
    7373        $actual   = esc_xml( $source );
    74         $this->assertEquals( $expected, $actual );
     74        $this->assertSame( $expected, $actual );
    7575    }
    7676
     
    8585    public function test_ignores_cdata_sections( $source, $expected ) {
    8686        $actual = esc_xml( $source );
    87         $this->assertEquals( $expected, $actual );
     87        $this->assertSame( $expected, $actual );
    8888    }
    8989
Note: See TracChangeset for help on using the changeset viewer.