From 693f85a2247ffb24d887f86bb8e7886e2c02fdb6 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 09:56:52 +0530 Subject: [PATCH 1/8] Replace assertEquals with assertSame in tests --- .../includes/misc/adminColorSchemePicker.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/tests/admin/includes/misc/adminColorSchemePicker.php b/tests/phpunit/tests/admin/includes/misc/adminColorSchemePicker.php index 7bde246c2bcca..d14a24d677ca4 100644 --- a/tests/phpunit/tests/admin/includes/misc/adminColorSchemePicker.php +++ b/tests/phpunit/tests/admin/includes/misc/adminColorSchemePicker.php @@ -217,7 +217,7 @@ public function test_admin_color_scheme_picker_sorting() { } $expected_order = array( 'modern', 'fresh', 'light', 'coffee', 'ocean' ); - $this->assertEquals( $expected_order, $found_colors, 'Color schemes should be ordered with modern, fresh, light first, followed by others alphabetically.' ); + $this->assertSame( $expected_order, $found_colors, 'Color schemes should be ordered with modern, fresh, light first, followed by others alphabetically.' ); } /** @@ -250,29 +250,29 @@ public function test_admin_color_scheme_picker_html_structure() { $xpath = new DOMXPath( $dom ); // Check fieldset and legend. - $this->assertEquals( 1, $xpath->query( '//fieldset[@id="color-picker"]' )->length ); - $this->assertEquals( 1, $xpath->query( '//legend' )->length ); + $this->assertSame( 1, $xpath->query( '//fieldset[@id="color-picker"]' )->length ); + $this->assertSame( 1, $xpath->query( '//legend' )->length ); // Check radio input. $radio = $xpath->query( '//input[@type="radio"][@value="modern"]' ); - $this->assertEquals( 1, $radio->length ); - $this->assertEquals( 'admin_color_modern', $radio->item( 0 )->getAttribute( 'id' ) ); + $this->assertSame( 1, $radio->length ); + $this->assertSame( 'admin_color_modern', $radio->item( 0 )->getAttribute( 'id' ) ); // Check hidden inputs. - $this->assertEquals( 1, $xpath->query( '//input[@type="hidden"][@class="css_url"][@value="https://example.com/modern.css"]' )->length ); + $this->assertSame( 1, $xpath->query( '//input[@type="hidden"][@class="css_url"][@value="https://example.com/modern.css"]' )->length ); $icon_colors_input = $xpath->query( '//input[@type="hidden"][@class="icon_colors"]' ); - $this->assertEquals( 1, $icon_colors_input->length ); + $this->assertSame( 1, $icon_colors_input->length ); $json_data = json_decode( $icon_colors_input->item( 0 )->getAttribute( 'value' ), true ); - $this->assertEquals( array( 'icons' => array( 'icons' => '#333' ) ), $json_data ); + $this->assertSame( array( 'icons' => array( 'icons' => '#333' ) ), $json_data ); // Check label. $label = $xpath->query( '//label[@for="admin_color_modern"]' ); - $this->assertEquals( 1, $label->length ); + $this->assertSame( 1, $label->length ); $this->assertStringContainsString( 'Modern Display Name', $label->item( 0 )->nodeValue ); // Check color palette. - $this->assertEquals( 2, $xpath->query( '//div[@class="color-palette-shade"]' )->length ); + $this->assertSame( 2, $xpath->query( '//div[@class="color-palette-shade"]' )->length ); $this->assertStringContainsString( 'background-color: #111', $output ); $this->assertStringContainsString( 'background-color: #222', $output ); } From 4ecad639324f01006fb6f31d8357d63fa79629d4 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 09:58:42 +0530 Subject: [PATCH 2/8] Change assertEquals to assertSame in test --- tests/phpunit/tests/functions/wpGetUpdatePhpAnnotation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpGetUpdatePhpAnnotation.php b/tests/phpunit/tests/functions/wpGetUpdatePhpAnnotation.php index a3d2bbb5d5c6b..c6e2f16203144 100644 --- a/tests/phpunit/tests/functions/wpGetUpdatePhpAnnotation.php +++ b/tests/phpunit/tests/functions/wpGetUpdatePhpAnnotation.php @@ -14,7 +14,7 @@ class Tests_functions_wpGetUpdatePhpAnnotation extends WP_UnitTestCase { * @ticket 59699 */ public function test_wp_get_update_php_annotation() { - $this->assertEquals( '', wp_get_update_php_annotation() ); + $this->assertSame( '', wp_get_update_php_annotation() ); } /** From 610c3b36578f041a9843ed4179cd388b561defb8 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 09:59:32 +0530 Subject: [PATCH 3/8] Add comment to clarify assertEquals usage --- .../tests/admin/includes/ajax-actions/saveAttachmentOrder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php index 86b91d8608699..485daf1d8c13a 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php @@ -96,6 +96,7 @@ public function test_save_attachment_order_success(): void { $this->assertTrue( $response['success'], 'AJAX response should be successful' ); + // Keep assertEquals() because WP_Post::$menu_order is a numeric string from the database. $this->assertEquals( 10, get_post( self::$attachment_ids[0] )->menu_order, 'First attachment menu_order should be 10' ); $this->assertEquals( 20, get_post( self::$attachment_ids[1] )->menu_order, 'Second attachment menu_order should be 20' ); } From 4664ab2f4bf228d22d6ccc6e55aa131892bea293 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 10:00:10 +0530 Subject: [PATCH 4/8] Keep `assertEquals()` for post_parent validation --- .../tests/admin/includes/ajax-actions/sendAttachmentToEditor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php b/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php index 99fd34a269180..970f95672bac7 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php @@ -93,6 +93,7 @@ public function test_send_attachment_to_editor_image_success(): void { // Verify that the attachment was attached to the post. $attachment = get_post( self::$attachment_id ); + // Keep assertEquals() because WP_Post::$post_parent is a numeric string from the database while the fixture ID is an integer. $this->assertEquals( self::$post_id, $attachment->post_parent, 'Attachment should be attached to the post' ); } From 95792130bee2cb59b24f583abefa705ff766cd49 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 10:01:03 +0530 Subject: [PATCH 5/8] Add comments for `assertEquals()` usage in tests --- tests/phpunit/tests/admin/includes/misc/setScreenOptions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php b/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php index b2441edd6639f..ad5b124944d4a 100644 --- a/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php +++ b/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php @@ -62,6 +62,7 @@ public function test_set_screen_options( $option, $value, $expected ) { } $meta = get_user_meta( $user_id, $option, true ); + // Keep assertEquals() because expected fixtures use integers while filter-passthrough options may store POST values as strings. $this->assertEquals( $expected, $meta ); } @@ -149,6 +150,7 @@ public function test_set_screen_options_with_filters() { } } + // Keep assertEquals() because the filter returns the raw POST string while the assertion uses an integer. $this->assertEquals( 25, get_user_meta( $user_id, 'custom_per_page', true ) ); } From 70c0830b3eea4a518c179e3f9ef49a466364301a Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 10:01:38 +0530 Subject: [PATCH 6/8] Clarify assertEquals usage in includesUpdate tests --- tests/phpunit/tests/admin/includesUpdate.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/tests/admin/includesUpdate.php b/tests/phpunit/tests/admin/includesUpdate.php index 7dfd156eaa17a..8a83d34cafe1d 100644 --- a/tests/phpunit/tests/admin/includesUpdate.php +++ b/tests/phpunit/tests/admin/includesUpdate.php @@ -144,6 +144,7 @@ public function test_wp_process_translation_update_selection_uses_current_packag $update->package = 'https://example.org/current.zip'; set_site_transient( 'update_plugins', (object) array( 'translations' => array( (array) $update ) ) ); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( array( $id => $update ), wp_process_translation_update_selection( array( $id ), array( $id ) ) @@ -496,6 +497,7 @@ static function ( $key ) use ( $updates ) { if ( false === $selected ) { $this->assertFalse( $actual ); } else { + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( wp_get_translation_updates_by_id( $get_updates( $selected ) ), $actual ); } From 83e665c9ce282d0625836316694805b95c0fd6a4 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 10:14:06 +0530 Subject: [PATCH 7/8] Replace `assertEquals` with `assertSame` for menu_order --- .../admin/includes/ajax-actions/saveAttachmentOrder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php index 485daf1d8c13a..babb4c18f66a9 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php @@ -96,9 +96,8 @@ public function test_save_attachment_order_success(): void { $this->assertTrue( $response['success'], 'AJAX response should be successful' ); - // Keep assertEquals() because WP_Post::$menu_order is a numeric string from the database. - $this->assertEquals( 10, get_post( self::$attachment_ids[0] )->menu_order, 'First attachment menu_order should be 10' ); - $this->assertEquals( 20, get_post( self::$attachment_ids[1] )->menu_order, 'Second attachment menu_order should be 20' ); + $this->assertSame( 10, get_post( self::$attachment_ids[0] )->menu_order, 'First attachment menu_order should be 10' ); + $this->assertSame( 20, get_post( self::$attachment_ids[1] )->menu_order, 'Second attachment menu_order should be 20' ); } /** From 3016a479f6e62b9a54897320c793dc867ebb0212 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 11 Nov 2026 10:14:42 +0530 Subject: [PATCH 8/8] Change `assertEquals` to `assertSame` for post parent check --- .../admin/includes/ajax-actions/sendAttachmentToEditor.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php b/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php index 970f95672bac7..40152b40aeb19 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/sendAttachmentToEditor.php @@ -93,8 +93,7 @@ public function test_send_attachment_to_editor_image_success(): void { // Verify that the attachment was attached to the post. $attachment = get_post( self::$attachment_id ); - // Keep assertEquals() because WP_Post::$post_parent is a numeric string from the database while the fixture ID is an integer. - $this->assertEquals( self::$post_id, $attachment->post_parent, 'Attachment should be attached to the post' ); + $this->assertSame( self::$post_id, $attachment->post_parent, 'Attachment should be attached to the post' ); } /**