From 06eeb2e78e7bde57a27e0a0d8433248863081205 Mon Sep 17 00:00:00 2001 From: haritpanchal Date: Fri, 18 Sep 2026 12:00:18 +0530 Subject: [PATCH] Build/Test Tools: Use strict assertions in the query tests. Trac ticket: https://core.trac.wordpress.org/ticket/64895 --- tests/phpunit/tests/query/cacheResults.php | 2 +- tests/phpunit/tests/query/results.php | 12 ++++++------ tests/phpunit/tests/query/setupPostdata.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/tests/query/cacheResults.php b/tests/phpunit/tests/query/cacheResults.php index 0c6783b6e73fc..41b73e12450d1 100644 --- a/tests/phpunit/tests/query/cacheResults.php +++ b/tests/phpunit/tests/query/cacheResults.php @@ -1485,7 +1485,7 @@ public function test_main_comments_feed_includes_attachment_comments() { $this->assertTrue( $query2->have_comments() ); $feed_comment = $query1->next_comment(); - $this->assertEquals( $comment_id, $feed_comment->comment_ID ); + $this->assertSame( (string) $comment_id, $feed_comment->comment_ID ); } /** diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index e9ec173d61dfd..e628bf6863ca8 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -1071,7 +1071,7 @@ public function test_post_password() { $result1 = $this->q->query( array_merge( $args, array( 'has_password' => true ) ) ); $this->assertEqualSets( array( $two, $three ), $result1 ); $result2 = $this->q->query( array_merge( $args, array( 'has_password' => false ) ) ); - $this->assertEquals( array( $one ), $result2 ); + $this->assertSame( array( (int) $one ), $result2 ); // This is equivalent to not passing it at all. $result3 = $this->q->query( array_merge( $args, array( 'has_password' => null ) ) ); @@ -1087,7 +1087,7 @@ public function test_post_password() { ) ) ); - $this->assertEquals( array( $one ), $result4 ); + $this->assertSame( array( (int) $one ), $result4 ); $result5 = $this->q->query( array_merge( $args, @@ -1097,7 +1097,7 @@ public function test_post_password() { ) ) ); - $this->assertEquals( array( $one ), $result5 ); + $this->assertSame( array( (int) $one ), $result5 ); $result6 = $this->q->query( array_merge( $args, @@ -1107,7 +1107,7 @@ public function test_post_password() { ) ) ); - $this->assertEquals( array( $one ), $result6 ); + $this->assertSame( array( (int) $one ), $result6 ); $result7 = $this->q->query( array_merge( @@ -1141,7 +1141,7 @@ public function test_post_password() { $this->assertEqualSets( array( $two, $three ), $result9 ); $result10 = $this->q->query( array_merge( $args, array( 'post_password' => '' ) ) ); - $this->assertEquals( array( $one ), $result10 ); + $this->assertSame( array( (int) $one ), $result10 ); $result11 = $this->q->query( array_merge( $args, array( 'post_password' => 'burrito' ) ) ); $this->assertEqualSets( array( $two, $three ), $result11 ); } @@ -1262,6 +1262,6 @@ public function test_main_comments_feed_includes_attachment_comments() { $this->assertTrue( $this->q->have_comments() ); $feed_comment = $this->q->next_comment(); - $this->assertEquals( $comment_id, $feed_comment->comment_ID ); + $this->assertSame( (string) $comment_id, $feed_comment->comment_ID ); } } diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index ef6b3479d8e33..9b93558e1dfcf 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -410,7 +410,7 @@ public function test_setup_postdata_with_the_content() { setup_postdata( $a_post ); $content = get_echo( 'the_content' ); $this->assertSame( $post_id, $GLOBALS['post']->ID ); - $this->assertNotEquals( '

global post

', strip_ws( $content ) ); + $this->assertNotSame( '

global post

', strip_ws( $content ) ); wp_reset_postdata(); }