From fda60db7bd8d27e0ab37a151055723a6a9f779b4 Mon Sep 17 00:00:00 2001 From: noruzzamans Date: Sat, 3 Oct 2026 00:38:35 +0600 Subject: [PATCH] Tests: Document value comparisons in post tests. See #64895. --- tests/phpunit/tests/post/getPageByPath.php | 2 ++ tests/phpunit/tests/post/meta.php | 2 ++ tests/phpunit/tests/post/types.php | 1 + tests/phpunit/tests/post/wpCountAttachments.php | 1 + 4 files changed, 6 insertions(+) diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index cad6446d82d3a..be09fcbc1a13e 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -38,9 +38,11 @@ public function test_get_page_by_path_priority() { $this->assertSame( 'some-page', $page->post_name ); // get_page_by_path() should return a post of the requested type before returning an attachment. + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $page, get_page_by_path( 'some-page' ) ); // Make sure get_page_by_path() will still select an attachment when a post of the requested type doesn't exist. + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $other_att, get_page_by_path( 'some-other-page' ) ); } diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 84a8558b7571b..5642f44732e83 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -171,6 +171,7 @@ public function test_get_post_meta_by_id() { $mobj->post_id = self::$post_id; $mobj->meta_key = 'get_post_meta_by_key'; $mobj->meta_value = 'get_post_meta_by_key_value'; + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $mobj, get_post_meta_by_id( $mid ) ); delete_metadata_by_mid( 'post', $mid ); @@ -178,6 +179,7 @@ public function test_get_post_meta_by_id() { $this->assertIsInt( $mid ); $mobj->meta_id = $mid; $mobj->meta_value = array( 'foo', 'bar' ); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $mobj, get_post_meta_by_id( $mid ) ); delete_metadata_by_mid( 'post', $mid ); } diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 0c470a0b3eff2..19df4b83bdbe1 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -292,6 +292,7 @@ public function test_get_post_type_object_casting() { $after = get_post_type_object( 'foo' )->labels; + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $before, $after ); _unregister_post_type( 'foo' ); diff --git a/tests/phpunit/tests/post/wpCountAttachments.php b/tests/phpunit/tests/post/wpCountAttachments.php index af895d3a7b7f4..fbe568a35eb3a 100644 --- a/tests/phpunit/tests/post/wpCountAttachments.php +++ b/tests/phpunit/tests/post/wpCountAttachments.php @@ -28,6 +28,7 @@ public function test_wp_count_attachments_should_cache_the_result() { $expected = wp_count_attachments( $mime_type ); $actual = wp_cache_get( $cache_key, 'counts' ); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $expected, $actual ); } }