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/date/getCommentDate.php

    r48924 r48937  
    1414        $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
    1515
    16         $this->assertEquals( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
     16        $this->assertSame( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
    1717    }
    1818
     
    2323        $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
    2424
    25         $this->assertEquals( 'August 29, 2020', get_comment_date( '', $c ) );
    26         $this->assertEquals( 'August 29, 2020', get_comment_date( false, $c ) );
     25        $this->assertSame( 'August 29, 2020', get_comment_date( '', $c ) );
     26        $this->assertSame( 'August 29, 2020', get_comment_date( false, $c ) );
    2727    }
    2828
     
    3434
    3535        $GLOBALS['comment'] = get_comment( $c );
    36         $this->assertEquals( '1:51 am', get_comment_time( 'g:i a' ) );
     36        $this->assertSame( '1:51 am', get_comment_time( 'g:i a' ) );
    3737    }
    3838
     
    4444
    4545        $GLOBALS['comment'] = get_comment( $c );
    46         $this->assertEquals( '1:51 am', get_comment_time( '' ) );
    47         $this->assertEquals( '1:51 am', get_comment_time( false ) );
     46        $this->assertSame( '1:51 am', get_comment_time( '' ) );
     47        $this->assertSame( '1:51 am', get_comment_time( false ) );
    4848    }
    4949}
Note: See TracChangeset for help on using the changeset viewer.