WordPress.org

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/import/postmeta.php

    r47198 r48937  
    2929        $expected['special_post_title'] = 'A special title';
    3030        $expected['is_calendar']        = '';
    31         $this->assertEquals( $expected, get_post_meta( 122, 'post-options', true ) );
     31        $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) );
    3232    }
    3333
     
    8585
    8686        // HTML in the CDATA should work with old WordPress version.
    87         $this->assertEquals( '<pre>some html</pre>', get_post_meta( 10, 'contains-html', true ) );
     87        $this->assertSame( '<pre>some html</pre>', get_post_meta( 10, 'contains-html', true ) );
    8888        // Serialised will only work with 3.0 onwards.
    8989        $expected['special_post_title'] = 'A special title';
    9090        $expected['is_calendar']        = '';
    91         $this->assertEquals( $expected, get_post_meta( 10, 'post-options', true ) );
     91        $this->assertSame( $expected, get_post_meta( 10, 'post-options', true ) );
    9292    }
    9393
     
    9898        $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) );
    9999        // Evil content in the CDATA.
    100         $this->assertEquals( '<wp:meta_value>evil</wp:meta_value>', get_post_meta( 10, 'evil', true ) );
     100        $this->assertSame( '<wp:meta_value>evil</wp:meta_value>', get_post_meta( 10, 'evil', true ) );
    101101    }
    102102}
Note: See TracChangeset for help on using the changeset viewer.