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/post/revisions.php

    r47122 r48937  
    6161
    6262        $lastrevision = end( $revisions );
    63         $this->assertEquals( 'I cant spel werds.', $lastrevision->post_content );
     63        $this->assertSame( 'I cant spel werds.', $lastrevision->post_content );
    6464        // #16215
    6565        $this->assertEquals( self::$author_user_id, $lastrevision->post_author );
     
    545545        $revisions = wp_get_post_revisions( $post['ID'] );
    546546
    547         $this->assertEquals( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
     547        $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
    548548    }
    549549
     
    580580        $revisions = wp_get_post_revisions( $post['ID'] );
    581581
    582         $this->assertEquals( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
     582        $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
    583583    }
    584584}
Note: See TracChangeset for help on using the changeset viewer.