Make WordPress Core

Changeset 57705


Ignore:
Timestamp:
02/24/2024 07:28:52 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in comment_exists() 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.

Follow-up to [34456], [34460].

Props costdev.
See #59655.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesComment.php

    r51724 r57705  
    5353    public function test_must_match_date_and_author() {
    5454        $this->assertNull( comment_exists( 1, '2004-01-02 12:00:00' ) );
    55         $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) );
     55        $this->assertSame( (string) self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) );
    5656    }
    5757
     
    6262     */
    6363    public function test_default_value_of_timezone_should_be_blog() {
    64         $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) );
     64        $this->assertSame( (string) self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) );
    6565    }
    6666
     
    7171     */
    7272    public function test_should_respect_timezone_blog() {
    73         $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'blog' ) );
     73        $this->assertSame( (string) self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'blog' ) );
    7474    }
    7575
     
    8080     */
    8181    public function test_should_respect_timezone_gmt() {
    82         $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 07:00:00', 'gmt' ) );
     82        $this->assertSame( (string) self::$post_id, comment_exists( 1, '2014-05-06 07:00:00', 'gmt' ) );
    8383    }
    8484
     
    8989     */
    9090    public function test_invalid_timezone_should_fall_back_on_blog() {
    91         $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'not_a_valid_value' ) );
     91        $this->assertSame( (string) self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'not_a_valid_value' ) );
    9292    }
    9393}
Note: See TracChangeset for help on using the changeset viewer.