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

    r46586 r48937  
    88        $input    = 'Captain <strong>Awesome</strong>';
    99        $expected = is_multisite() ? 'captain awesome' : 'Captain Awesome';
    10         $this->assertEquals( $expected, sanitize_user( $input ) );
     10        $this->assertSame( $expected, sanitize_user( $input ) );
    1111    }
    1212
     
    1919        }
    2020
    21         $this->assertEquals( $expected, sanitize_user( 'AT&amp;T' ) );
     21        $this->assertSame( $expected, sanitize_user( 'AT&amp;T' ) );
    2222    }
    2323
     
    3030        }
    3131
    32         $this->assertEquals( $expected, sanitize_user( 'AT&amp;T Test;' ) );
     32        $this->assertSame( $expected, sanitize_user( 'AT&amp;T Test;' ) );
    3333    }
    3434
    3535    function test_strips_percent_encoded_octets() {
    3636        $expected = is_multisite() ? 'franois' : 'Franois';
    37         $this->assertEquals( $expected, sanitize_user( 'Fran%c3%a7ois' ) );
     37        $this->assertSame( $expected, sanitize_user( 'Fran%c3%a7ois' ) );
    3838    }
    3939    function test_optional_strict_mode_reduces_to_safe_ascii_subset() {
    40         $this->assertEquals( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) );
     40        $this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) );
    4141    }
    4242}
Note: See TracChangeset for help on using the changeset viewer.