Skip to content

Commit 7ee50fe

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@57705 602fd350-edb4-49c9-b593-d223f7449a82
1 parent aea8a21 commit 7ee50fe

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/phpunit/tests/admin/includesComment.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
5252
*/
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

5858
/**
@@ -61,7 +61,7 @@ public function test_must_match_date_and_author() {
6161
* @covers ::comment_exists
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

6767
/**
@@ -70,7 +70,7 @@ public function test_default_value_of_timezone_should_be_blog() {
7070
* @covers ::comment_exists
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

7676
/**
@@ -79,7 +79,7 @@ public function test_should_respect_timezone_blog() {
7979
* @covers ::comment_exists
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

8585
/**
@@ -88,6 +88,6 @@ public function test_should_respect_timezone_gmt() {
8888
* @covers ::comment_exists
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
}

0 commit comments

Comments
 (0)