Skip to content

Commit

Permalink
Tests: Use assertSame() in WP_Comment::get_instance() tests.
Browse files Browse the repository at this point in the history
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 [38381].

Props costdev.
See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58054 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Apr 29, 2024
1 parent e9bea6d commit d1e0a62
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/phpunit/tests/comment/wpComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
public function test_get_instance_should_work_for_numeric_string() {
$found = WP_Comment::get_instance( (string) self::$comment_id );

$this->assertEquals( self::$comment_id, $found->comment_ID );
$this->assertSame( (string) self::$comment_id, $found->comment_ID );
}

/**
Expand All @@ -60,6 +60,6 @@ public function test_get_instance_should_fail_for_non_numeric_string() {
public function test_get_instance_should_succeed_for_float_that_is_equal_to_post_id() {
$found = WP_Comment::get_instance( 1.0 );

$this->assertEquals( 1, $found->comment_ID );
$this->assertSame( '1', $found->comment_ID );
}
}

0 comments on commit d1e0a62

Please sign in to comment.