From 20dbd95e26814217ee221e8c82652611216dd120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20W=C3=BCnsch?= Date: Tue, 14 Jul 2026 07:45:26 +0200 Subject: [PATCH] Tests: Use `assertTrue()`/`assertFalse()` instead of `assertSame()` with boolean values. Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages. --- tests/phpunit/tests/blocks/wpBlockType.php | 8 ++++---- .../interactivity-api/wpInteractivityAPI-wp-bind.php | 4 ++-- tests/phpunit/tests/rest-api/rest-post-meta-fields.php | 2 +- tests/phpunit/tests/rest-api/wpRestMenusController.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/tests/blocks/wpBlockType.php b/tests/phpunit/tests/blocks/wpBlockType.php index a73efa8ce8a7d..3e69b67d965db 100644 --- a/tests/phpunit/tests/blocks/wpBlockType.php +++ b/tests/phpunit/tests/blocks/wpBlockType.php @@ -528,9 +528,9 @@ public function test_variations_callback_are_lazy_loaded() { ) ); - $this->assertSame( false, $callback_called, 'The callback should not be called before the variations are accessed.' ); + $this->assertFalse( $callback_called, 'The callback should not be called before the variations are accessed.' ); $block_type->variations; // access the variations. - $this->assertSame( true, $callback_called, 'The callback should be called when the variations are accessed.' ); + $this->assertTrue( $callback_called, 'The callback should be called when the variations are accessed.' ); } /** @@ -555,7 +555,7 @@ public function test_variations_precedence_over_callback_post_registration() { // If the variations are defined after registration but before first access, the callback should not override it. $this->assertSameSets( $test_variations, $block_type->get_variations(), 'Variations are same as variations set' ); - $this->assertSame( false, $callback_called, 'The callback was never called.' ); + $this->assertFalse( $callback_called, 'The callback was never called.' ); } /** @@ -617,7 +617,7 @@ public function test_get_block_type_variations_filter_with_variation_callback() $obtained_variations = $block_type->variations; // access the variations. - $this->assertSame( true, $callback_called, 'The callback should be called when the variations are accessed.' ); + $this->assertTrue( $callback_called, 'The callback should be called when the variations are accessed.' ); $this->assertSameSets( $obtained_variations, $expected_variations, 'The variations obtained from the callback should be filtered.' ); } diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php index 02fc0d09293f7..ee9220dfd060a 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php @@ -410,7 +410,7 @@ public function test_wp_bind_handles_nested_bindings() { public function test_wp_bind_handles_true_value() { $html = '
'; list($p) = $this->process_directives( $html ); - $this->assertSame( true, $p->get_attribute( 'id' ) ); + $this->assertTrue( $p->get_attribute( 'id' ) ); } /** @@ -423,7 +423,7 @@ public function test_wp_bind_handles_true_value() { public function test_wp_bind_ignores_unique_ids() { $html = '
'; list($p) = $this->process_directives( $html ); - $this->assertSame( true, $p->get_attribute( 'id' ) ); + $this->assertTrue( $p->get_attribute( 'id' ) ); $html = '
'; list($p) = $this->process_directives( $html ); diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index 5ce72a57fa55f..0f8584f469892 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -2348,7 +2348,7 @@ public function test_update_meta_with_unchanged_values_and_custom_authentication $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( false, $data['meta']['authenticated'] ); + $this->assertFalse( $data['meta']['authenticated'] ); } /** diff --git a/tests/phpunit/tests/rest-api/wpRestMenusController.php b/tests/phpunit/tests/rest-api/wpRestMenusController.php index 864b09417d2cb..46f9877e3cfc0 100644 --- a/tests/phpunit/tests/rest-api/wpRestMenusController.php +++ b/tests/phpunit/tests/rest-api/wpRestMenusController.php @@ -316,7 +316,7 @@ public function test_update_item() { $data = $response->get_data(); $this->assertSame( 'New Name', $data['name'] ); $this->assertSame( 'New Description', $data['description'] ); - $this->assertSame( true, $data['auto_add'] ); + $this->assertTrue( $data['auto_add'] ); $this->assertSame( 'new-name', $data['slug'] ); $this->assertSame( 'just meta', $data['meta']['test_single_menu'] ); $this->assertFalse( isset( $data['meta']['test_cat_meta'] ) );