From eeaea4bfce8ee7392c725943eb3466af65adf0ff Mon Sep 17 00:00:00 2001 From: scruffian Date: Wed, 19 Jul 2023 12:36:46 +0100 Subject: [PATCH 01/16] Navigation: Load the raw property on the navigation fallback --- lib/compat/wordpress-6.3/navigation-fallback.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/compat/wordpress-6.3/navigation-fallback.php b/lib/compat/wordpress-6.3/navigation-fallback.php index f3a22e5ce997c..919d0960eaf94 100644 --- a/lib/compat/wordpress-6.3/navigation-fallback.php +++ b/lib/compat/wordpress-6.3/navigation-fallback.php @@ -26,10 +26,17 @@ function gutenberg_add_fields_to_navigation_fallback_embeded_links( $schema ) { $schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) ); // Expose sub properties of content field. + // These aren't exposed by the posts controller by default, see: + // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2425 $schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) ); $schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) ); $schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) ); + // Expose sub properties of title field. + // These aren't exposed by the posts controller by default, see: + // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2401 + //$schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) ); + return $schema; } From 2e7b14b1fe9b44c7e84a51b24b723db1bc51146a Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 19 Jul 2023 13:02:09 +0100 Subject: [PATCH 02/16] Update lib/compat/wordpress-6.3/navigation-fallback.php Co-authored-by: Dave Smith --- lib/compat/wordpress-6.3/navigation-fallback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.3/navigation-fallback.php b/lib/compat/wordpress-6.3/navigation-fallback.php index 919d0960eaf94..0feb34acbeee8 100644 --- a/lib/compat/wordpress-6.3/navigation-fallback.php +++ b/lib/compat/wordpress-6.3/navigation-fallback.php @@ -27,7 +27,7 @@ function gutenberg_add_fields_to_navigation_fallback_embeded_links( $schema ) { // Expose sub properties of content field. // These aren't exposed by the posts controller by default, see: - // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2425 + // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2425. $schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) ); $schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) ); $schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) ); From e6f9b64f31cdad6602a5de8bdef8da0187461d5b Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 19 Jul 2023 13:02:19 +0100 Subject: [PATCH 03/16] Update lib/compat/wordpress-6.3/navigation-fallback.php Co-authored-by: Dave Smith --- lib/compat/wordpress-6.3/navigation-fallback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.3/navigation-fallback.php b/lib/compat/wordpress-6.3/navigation-fallback.php index 0feb34acbeee8..5619e3204627a 100644 --- a/lib/compat/wordpress-6.3/navigation-fallback.php +++ b/lib/compat/wordpress-6.3/navigation-fallback.php @@ -34,8 +34,8 @@ function gutenberg_add_fields_to_navigation_fallback_embeded_links( $schema ) { // Expose sub properties of title field. // These aren't exposed by the posts controller by default, see: - // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2401 - //$schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) ); + // https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2401. + $schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) ); return $schema; } From f4a01447f49741e9749037a71dd8eeb949a9e569 Mon Sep 17 00:00:00 2001 From: scruffian Date: Thu, 20 Jul 2023 12:26:06 +0100 Subject: [PATCH 04/16] Add a test for these properties --- ...st-navigation-fallback-controller-test.php | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 14ab8ee0971dd..f08ca03581ee2 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -158,10 +158,39 @@ public function test_prepare_item() { } /** - * @doesNotPerformAssertions + * Tests that the correct filters are applied to the context parameter. + * + * The REST response for the Posts Controller doesn't return all fields, + * when the context is set to embed. We need to add additional fields + * for the navigation fallback, so that when it embeds a navigation, + * the required fields are present. + * + * @covers wp_add_fields_to_navigation_fallback_embeded_links */ public function test_context_param() { - // Covered by the core test. + // First we'll use the navigation fallback to get a link to the navigation endpoint. + $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); + $response = rest_get_server()->dispatch( $request ); + $links = $response->get_links(); + + // Extract the navigation endpoint URL from the response. + $embedded_navigation_href = $links['self'][0]['href']; + preg_match('/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); + $navigation_endpoint = $matches[1]; + + // Fetch a navigation from the endpoint, with the context parameter set to embed. + $request = new WP_REST_Request( 'GET', $navigation_endpoint ); + $request->set_param( 'context', 'embed' ); + $response = rest_get_server()->dispatch( $request ); + $data = $response->get_data(); + + // Verify that the additional fields are present. + $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'content', $data, 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'rendered', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'block_version', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); } /** From f7691763cc21a9bb96c47a68bc5de786aa7f1075 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:47:05 +0100 Subject: [PATCH 05/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index f08ca03581ee2..a39ce50cecbde 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -175,7 +175,7 @@ public function test_context_param() { // Extract the navigation endpoint URL from the response. $embedded_navigation_href = $links['self'][0]['href']; - preg_match('/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); + preg_match( '/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); $navigation_endpoint = $matches[1]; // Fetch a navigation from the endpoint, with the context parameter set to embed. From 358d8a60f1c4b15fe367db82d5b143edec367971 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:47:19 +0100 Subject: [PATCH 06/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index a39ce50cecbde..63cd8d416b0c8 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -185,7 +185,7 @@ public function test_context_param() { $data = $response->get_data(); // Verify that the additional fields are present. - $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); $this->assertArrayHasKey( 'content', $data, 'Response title should contain a "raw" key.' ); $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); $this->assertArrayHasKey( 'rendered', $data['content'], 'Response title should contain a "raw" key.' ); From 955671557411c29c95cad686ccab5eae8bceeb40 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:47:30 +0100 Subject: [PATCH 07/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 63cd8d416b0c8..3955d690dbbe4 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -178,7 +178,7 @@ public function test_context_param() { preg_match( '/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); $navigation_endpoint = $matches[1]; - // Fetch a navigation from the endpoint, with the context parameter set to embed. + // Fetch the "linked" navigation post from the endpoint, with the context parameter set to 'embed' to simulate fetching embedded links. $request = new WP_REST_Request( 'GET', $navigation_endpoint ); $request->set_param( 'context', 'embed' ); $response = rest_get_server()->dispatch( $request ); From e9ffa47a8f3e4d1d1d405fec5c80d5c615c87899 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:47:44 +0100 Subject: [PATCH 08/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 3955d690dbbe4..8cf62ad07897e 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -186,7 +186,7 @@ public function test_context_param() { // Verify that the additional fields are present. $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); - $this->assertArrayHasKey( 'content', $data, 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); $this->assertArrayHasKey( 'rendered', $data['content'], 'Response title should contain a "raw" key.' ); $this->assertArrayHasKey( 'block_version', $data['content'], 'Response title should contain a "raw" key.' ); From 105c338f17a4ef42f588f34250372381a0156b12 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:48:05 +0100 Subject: [PATCH 09/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...gutenberg-rest-navigation-fallback-controller-test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 8cf62ad07897e..4f640505fa2db 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -160,10 +160,10 @@ public function test_prepare_item() { /** * Tests that the correct filters are applied to the context parameter. * - * The REST response for the Posts Controller doesn't return all fields, - * when the context is set to embed. We need to add additional fields - * for the navigation fallback, so that when it embeds a navigation, - * the required fields are present. + * By default, the REST response for the Posts Controller will not return all fields + * when the context is set to 'embed'. Assert that correct additional fields are added + * to the embedded Navigation Post, when the navigation fallback endpoint + * is called with the `_embed` param. * * @covers wp_add_fields_to_navigation_fallback_embeded_links */ From 643492de3ea9db72787ee6598a8c2f81d4f0a4fc Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:48:12 +0100 Subject: [PATCH 10/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 4f640505fa2db..020a9cf93de5a 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -167,7 +167,7 @@ public function test_prepare_item() { * * @covers wp_add_fields_to_navigation_fallback_embeded_links */ - public function test_context_param() { + public function test_embedded_navigation_post_contains_required_fields() { // First we'll use the navigation fallback to get a link to the navigation endpoint. $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); $response = rest_get_server()->dispatch( $request ); From 8e9347c239cf6bda0cfa9d8b7f1e22a683f0f83c Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:48:26 +0100 Subject: [PATCH 11/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 020a9cf93de5a..cacd96d59b711 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -189,7 +189,7 @@ public function test_embedded_navigation_post_contains_required_fields() { $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); $this->assertArrayHasKey( 'rendered', $data['content'], 'Response title should contain a "raw" key.' ); - $this->assertArrayHasKey( 'block_version', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'block_version', $data['content'], 'Response should contain a "block_version" field.' ); $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); } From 5a6aa8472b51928b781fe3625ca8255e8391153c Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:48:33 +0100 Subject: [PATCH 12/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index cacd96d59b711..095845f36cba8 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -188,7 +188,7 @@ public function test_embedded_navigation_post_contains_required_fields() { $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); - $this->assertArrayHasKey( 'rendered', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'rendered', $data['content'], 'Response content should contain a "rendered" field.' ); $this->assertArrayHasKey( 'block_version', $data['content'], 'Response should contain a "block_version" field.' ); $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); } From e65b9b5d7dc6c17e82a2f6f0c65d004d0fce96f8 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 20 Jul 2023 12:48:39 +0100 Subject: [PATCH 13/16] Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php Co-authored-by: Dave Smith --- ...class-gutenberg-rest-navigation-fallback-controller-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 095845f36cba8..9c53274e89b2e 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -187,7 +187,7 @@ public function test_embedded_navigation_post_contains_required_fields() { // Verify that the additional fields are present. $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); - $this->assertArrayHasKey( 'raw', $data['content'], 'Response title should contain a "raw" key.' ); + $this->assertArrayHasKey( 'raw', $data['content'], 'Response content should contain a "raw" field.' ); $this->assertArrayHasKey( 'rendered', $data['content'], 'Response content should contain a "rendered" field.' ); $this->assertArrayHasKey( 'block_version', $data['content'], 'Response should contain a "block_version" field.' ); $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); From c670ac315701ba3620811e691b958f9aca51030e Mon Sep 17 00:00:00 2001 From: scruffian Date: Thu, 20 Jul 2023 12:53:44 +0100 Subject: [PATCH 14/16] add more comments --- ...gutenberg-rest-navigation-fallback-controller-test.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 9c53274e89b2e..4e0aca973ad14 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -162,7 +162,7 @@ public function test_prepare_item() { * * By default, the REST response for the Posts Controller will not return all fields * when the context is set to 'embed'. Assert that correct additional fields are added - * to the embedded Navigation Post, when the navigation fallback endpoint + * to the embedded Navigation Post, when the navigation fallback endpoint * is called with the `_embed` param. * * @covers wp_add_fields_to_navigation_fallback_embeded_links @@ -184,12 +184,16 @@ public function test_embedded_navigation_post_contains_required_fields() { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - // Verify that the additional fields are present. + // Verify that the additional status field is present. $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); + + // Verify that the additional content fields are present. $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); $this->assertArrayHasKey( 'raw', $data['content'], 'Response content should contain a "raw" field.' ); $this->assertArrayHasKey( 'rendered', $data['content'], 'Response content should contain a "rendered" field.' ); $this->assertArrayHasKey( 'block_version', $data['content'], 'Response should contain a "block_version" field.' ); + + // Verify that the additional title.raw field is present. $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); } From 2b77066538d696a967dbf8b2ee2b09d2168ded50 Mon Sep 17 00:00:00 2001 From: scruffian Date: Thu, 20 Jul 2023 12:57:42 +0100 Subject: [PATCH 15/16] add necessary method --- ...-gutenberg-rest-navigation-fallback-controller-test.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 4e0aca973ad14..f01fc1986a218 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -197,6 +197,13 @@ public function test_embedded_navigation_post_contains_required_fields() { $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); } + /** + * @doesNotPerformAssertions + */ + public function test_context_param() { + // Covered by the core test. + } + /** * @doesNotPerformAssertions */ From 2e561dcf3b957471302df9fd84a49b9de38ccf11 Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Thu, 20 Jul 2023 13:32:12 -0500 Subject: [PATCH 16/16] Fix php coding standards error --- ...ass-gutenberg-rest-navigation-fallback-controller-test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index f01fc1986a218..70d84cb716951 100644 --- a/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -171,7 +171,7 @@ public function test_embedded_navigation_post_contains_required_fields() { // First we'll use the navigation fallback to get a link to the navigation endpoint. $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); $response = rest_get_server()->dispatch( $request ); - $links = $response->get_links(); + $links = $response->get_links(); // Extract the navigation endpoint URL from the response. $embedded_navigation_href = $links['self'][0]['href']; @@ -179,7 +179,7 @@ public function test_embedded_navigation_post_contains_required_fields() { $navigation_endpoint = $matches[1]; // Fetch the "linked" navigation post from the endpoint, with the context parameter set to 'embed' to simulate fetching embedded links. - $request = new WP_REST_Request( 'GET', $navigation_endpoint ); + $request = new WP_REST_Request( 'GET', $navigation_endpoint ); $request->set_param( 'context', 'embed' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data();