Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (5 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/date/getTheDate.php

    r48924 r48937  
    1414        $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    1515
    16         $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
     16        $this->assertSame( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
    1717    }
    1818
     
    3333        $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) );
    3434
    35         $this->assertEquals( 'August 29, 2020', get_the_date( '', $post_id ) );
    36         $this->assertEquals( 'August 29, 2020', get_the_date( false, $post_id ) );
     35        $this->assertSame( 'August 29, 2020', get_the_date( '', $post_id ) );
     36        $this->assertSame( 'August 29, 2020', get_the_date( false, $post_id ) );
    3737    }
    3838
     
    4343        $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    4444
    45         $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
     45        $this->assertSame( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
    4646    }
    4747
     
    6262        $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) );
    6363
    64         $this->assertEquals( '1:51 am', get_the_time( '', $post_id ) );
    65         $this->assertEquals( '1:51 am', get_the_time( false, $post_id ) );
     64        $this->assertSame( '1:51 am', get_the_time( '', $post_id ) );
     65        $this->assertSame( '1:51 am', get_the_time( false, $post_id ) );
    6666    }
    6767}
Note: See TracChangeset for help on using the changeset viewer.