Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months 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/anonymization.php

    r48100 r48937  
    3737        /* Todo test ipv6_fallback mode if keeping it.*/
    3838
    39         $this->assertEquals( $expected_result, $actual_result );
     39        $this->assertSame( $expected_result, $actual_result );
    4040    }
    4141
     
    227227     */
    228228    public function test_anonymize_date() {
    229         $this->assertEquals( '0000-00-00 00:00:00', wp_privacy_anonymize_data( 'date', '2003-12-25 12:34:56' ) );
     229        $this->assertSame( '0000-00-00 00:00:00', wp_privacy_anonymize_data( 'date', '2003-12-25 12:34:56' ) );
    230230    }
    231231
     
    235235    public function test_anonymize_text() {
    236236        $text = __( 'Four score and seven years ago' );
    237         $this->assertEquals( '[deleted]', wp_privacy_anonymize_data( 'text', $text ) );
     237        $this->assertSame( '[deleted]', wp_privacy_anonymize_data( 'text', $text ) );
    238238    }
    239239
     
    243243    public function test_anonymize_long_text() {
    244244        $text = __( 'Four score and seven years ago' );
    245         $this->assertEquals( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) );
     245        $this->assertSame( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) );
    246246    }
    247247
Note: See TracChangeset for help on using the changeset viewer.