diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 512043fb4ec04..e1c4983be32c8 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -380,6 +380,7 @@ public function test_get_item_default_attributes() { $data = $response->get_data(); $this->assertSame( $defaults, json_decode( $data['rendered'], true ) ); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( json_decode( $block_type->render( $defaults ) ), json_decode( $data['rendered'] ) diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 412da7d560a75..aa68de786740d 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -1175,6 +1175,7 @@ public function test_get_user_empty_capabilities() { } else { $data = $response->get_data(); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( $data['capabilities'], new stdClass() ); $this->assertEquals( $data['extra_capabilities'], new stdClass() ); } @@ -3355,6 +3356,7 @@ protected function check_user_data( $user, $data, $context, $links ) { $this->assertSame( $user->last_name, $data['last_name'] ); $this->assertSame( $user->nickname, $data['nickname'] ); $this->assertSame( $user->user_email, $data['email'] ); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( (object) $user->allcaps, $data['capabilities'] ); $this->assertEquals( (object) $user->caps, $data['extra_capabilities'] ); $this->assertSame( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] ); diff --git a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php index 3f31831a825a5..0315b67dd9997 100644 --- a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php +++ b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php @@ -435,7 +435,7 @@ public function test_get_item_public_meta_exposes_in_rest(): void { $request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/public-ability' ); $response = $this->server->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['meta']['public'] ); @@ -466,7 +466,7 @@ public function test_get_item_public_true_show_in_rest_false_is_hidden(): void { $request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/public-optout' ); $response = $this->server->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); $data = $response->get_data(); $this->assertSame( 'rest_ability_not_found', $data['code'] ); diff --git a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php index e546ce05fd29e..5edcb00690a99 100644 --- a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php +++ b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php @@ -429,7 +429,7 @@ public function test_execute_regular_ability_post(): void { $response = $this->server->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); - $this->assertEquals( 8, $response->get_data() ); + $this->assertSame( 8.0, $response->get_data() ); } /** @@ -451,7 +451,7 @@ public function test_execute_readonly_ability_get(): void { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( self::$user_id, $data['id'] ); + $this->assertSame( self::$user_id, $data['id'] ); } /** @@ -675,7 +675,7 @@ public function test_run_public_meta_ability_is_executable(): void { $response = $this->server->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( $response->get_data() ); } @@ -789,7 +789,7 @@ public function test_get_request_with_nested_input_array(): void { $data = $response->get_data(); $this->assertSame( 'nested', $data['level1']['level2']['value'] ); - $this->assertEquals( array( 1, 2, 3 ), $data['array'] ); + $this->assertSame( array( 1, 2, 3 ), $data['array'] ); } /** @@ -1297,7 +1297,7 @@ public function test_php_type_strings_in_input(): void { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $inputs, $data['echo'] ); + $this->assertSame( $inputs, $data['echo'] ); } /** @@ -1346,9 +1346,9 @@ public function test_mixed_encoding_in_input(): void { $data = $response->get_data(); // Input should be preserved exactly - $this->assertEquals( $input['utf8'], $data['echo']['utf8'] ); - $this->assertEquals( $input['emoji'], $data['echo']['emoji'] ); - $this->assertEquals( $input['html'], $data['echo']['html'] ); + $this->assertSame( $input['utf8'], $data['echo']['utf8'] ); + $this->assertSame( $input['emoji'], $data['echo']['emoji'] ); + $this->assertSame( $input['html'], $data['echo']['html'] ); } /** diff --git a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php index 1f52c315e3a7c..f881ca1dede87 100644 --- a/tests/phpunit/tests/rest-api/wpRestTemplatesController.php +++ b/tests/phpunit/tests/rest-api/wpRestTemplatesController.php @@ -1181,6 +1181,7 @@ public function test_get_template_fallback_not_found() { $request->set_param( 'slug', 'not-found' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); + // Keep assertEquals() because the objects are intentionally compared by value. $this->assertEquals( new stdClass(), $data, 'Response should be an empty object when a fallback template is not found.' ); }