From 1548281b5a9d9a61de4b30566f794094e329685c Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 15:28:50 +0530 Subject: [PATCH 1/7] feat: Add tests for CoreParagraph block --- tests/unit/CoreParagraphTest.php | 336 +++++++++++++++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 tests/unit/CoreParagraphTest.php diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php new file mode 100644 index 00000000..eaf43bc4 --- /dev/null +++ b/tests/unit/CoreParagraphTest.php @@ -0,0 +1,336 @@ +post_id = wp_insert_post( + [ + 'post_title' => 'Post with Paragraph', + 'post_content' => '', + 'post_status' => 'publish', + ] + ); + + \WPGraphQL::clear_schema(); + } + + /** + * Tear down the test environment. + */ + public function tearDown(): void { + parent::tearDown(); + + wp_delete_post( $this->post_id, true ); + + \WPGraphQL::clear_schema(); + } + + /** + * Provide the GraphQL query for testing. + * + * @return string The GraphQL query. + */ + public function query(): string { + return ' + fragment CoreParagraphBlockFragment on CoreParagraph { + attributes { + align + anchor + backgroundColor + className + content + cssClassName + dropCap + direction + fontFamily + fontSize + gradient + lock + metadata + placeholder + style + textColor + } + } + query Post( $id: ID! ) { + post(id: $id, idType: DATABASE_ID) { + databaseId + editorBlocks { + name + ...CoreParagraphBlockFragment + } + } + } + '; + } + + /** + * Test the retrieval of core/paragraph block attributes. + * + * Attributes covered: + * - align + * - backgroundColor + * - textColor + * - fontSize + * - fontFamily + * - content + * - cssClassName + * + * @return void + */ + public function test_retrieve_core_paragraph_attributes() { + $block_content = ' + +

This is a test paragraph with various attributes.

+ + '; + + wp_update_post( + [ + 'ID' => $this->post_id, + 'post_content' => $block_content, + ] + ); + + $actual = graphql( + [ + 'query' => $this->query(), + 'variables' => [ 'id' => $this->post_id ], + ] + ); + + $this->assertArrayNotHasKey( 'errors', $actual ); + $this->assertArrayHasKey( 'data', $actual ); + $this->assertArrayHasKey( 'post', $actual['data'] ); + + $block = $actual['data']['post']['editorBlocks'][0]; + $attributes = $block['attributes']; + + $this->assertEquals( 'core/paragraph', $block['name'] ); + $this->assertEquals( + [ + 'align' => 'center', + 'anchor' => null, + 'backgroundColor' => 'pale-cyan-blue', + 'className' => null, + 'content' => 'This is a test paragraph with various attributes.', + 'cssClassName' => 'has-text-align-center has-vivid-red-color has-pale-cyan-blue-background-color has-text-color has-background has-large-font-size has-helvetica-arial-font-family', + 'dropCap' => false, + 'direction' => null, + 'fontFamily' => 'helvetica-arial', + 'fontSize' => 'large', + 'gradient' => null, + 'lock' => null, + 'metadata' => null, + 'placeholder' => null, + 'style' => null, + 'textColor' => 'vivid-red', + ], + $attributes + ); + } + + /** + * Test retrieval of core/paragraph block with drop cap and custom styles. + * + * Attributes covered: + * - dropCap + * - style (typography and spacing) + * - content + * - cssClassName + * + * @return void + */ + public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { + $block_content = ' + +

This is a paragraph with drop cap and custom styles.

+ + '; + + wp_update_post( + [ + 'ID' => $this->post_id, + 'post_content' => $block_content, + ] + ); + + $actual = graphql( + [ + 'query' => $this->query(), + 'variables' => [ 'id' => $this->post_id ], + ] + ); + + $block = $actual['data']['post']['editorBlocks'][0]; + $attributes = $block['attributes']; + + $this->assertEquals( + [ + 'align' => null, + 'anchor' => null, + 'backgroundColor' => null, + 'className' => null, + 'content' => 'This is a paragraph with drop cap and custom styles.', + 'cssClassName' => 'has-drop-cap', + 'dropCap' => true, + 'direction' => null, + 'fontFamily' => null, + 'fontSize' => null, + 'gradient' => null, + 'lock' => null, + 'metadata' => null, + 'placeholder' => null, + 'style' => wp_json_encode( + [ + 'typography' => [ + 'lineHeight' => '2', + 'textTransform' => 'uppercase', + ], + 'spacing' => [ + 'padding' => [ + 'top' => '20px', + 'right' => '20px', + 'bottom' => '20px', + 'left' => '20px', + ], + ], + ] + ), + 'textColor' => null, + ], + $attributes + ); + } + + /** + * Test retrieval of core/paragraph block with direction and gradient. + * + * Attributes covered: + * - align + * - direction + * - gradient + * - content + * - cssClassName + * + * @return void + */ + public function test_retrieve_core_paragraph_with_direction_and_gradient() { + $block_content = ' + +

This is a right-aligned RTL paragraph with a gradient background.

+ + '; + + wp_update_post( + [ + 'ID' => $this->post_id, + 'post_content' => $block_content, + ] + ); + + $actual = graphql( + [ + 'query' => $this->query(), + 'variables' => [ 'id' => $this->post_id ], + ] + ); + + $block = $actual['data']['post']['editorBlocks'][0]; + $attributes = $block['attributes']; + + $this->assertEquals( + [ + 'align' => 'right', + 'anchor' => null, + 'backgroundColor' => null, + 'className' => null, + 'content' => 'This is a right-aligned RTL paragraph with a gradient background.', + 'cssClassName' => 'has-text-align-right has-vivid-cyan-blue-to-vivid-purple-gradient-background', + 'dropCap' => false, + 'direction' => 'rtl', + 'fontFamily' => null, + 'fontSize' => null, + 'gradient' => 'vivid-cyan-blue-to-vivid-purple', + 'lock' => null, + 'metadata' => null, + 'placeholder' => null, + 'style' => null, + 'textColor' => null, + ], + $attributes + ); + } + + /** + * Test retrieval of core/paragraph block with additional attributes. + * + * Attributes covered: + * - anchor + * - className + * - lock + * - metadata + * - placeholder + * + * @return void + */ + public function test_retrieve_core_paragraph_with_additional_attributes() { + $block_content = ' + +

This is a paragraph with additional attributes.

+ + '; + + wp_update_post( + [ + 'ID' => $this->post_id, + 'post_content' => $block_content, + ] + ); + + $actual = graphql( + [ + 'query' => $this->query(), + 'variables' => [ 'id' => $this->post_id ], + ] + ); + + $block = $actual['data']['post']['editorBlocks'][0]; + $attributes = $block['attributes']; + + $this->assertEquals( + [ + 'align' => null, + 'anchor' => 'test-anchor', + 'backgroundColor' => null, + 'className' => 'custom-class', + 'content' => 'This is a paragraph with additional attributes.', + 'cssClassName' => 'custom-class', + 'dropCap' => false, + 'direction' => null, + 'fontFamily' => null, + 'fontSize' => null, + 'gradient' => null, + 'lock' => '{"move":true,"remove":true}', + 'metadata' => '{"someKey":"someValue"}', + 'placeholder' => 'Type here...', + 'style' => null, + 'textColor' => null, + ], + $attributes + ); + } +} From 962081dfef4a468674b1753568e37bc0a73114da Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 15:43:11 +0530 Subject: [PATCH 2/7] feat: Add changeset to tests --- .changeset/olive-clocks-clean.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/olive-clocks-clean.md diff --git a/.changeset/olive-clocks-clean.md b/.changeset/olive-clocks-clean.md new file mode 100644 index 00000000..105d8570 --- /dev/null +++ b/.changeset/olive-clocks-clean.md @@ -0,0 +1,5 @@ +--- +"@wpengine/wp-graphql-content-blocks": patch +--- + +tests: Add tests for CoreParagraph block From 1b26edbbad4d2a77c4594e65c1725d410a5bfec9 Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 17:06:54 +0530 Subject: [PATCH 3/7] fix: Add missing asserts --- tests/unit/CoreParagraphTest.php | 221 +++++++++++++++++++------------ 1 file changed, 138 insertions(+), 83 deletions(-) diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php index eaf43bc4..d3aa169e 100644 --- a/tests/unit/CoreParagraphTest.php +++ b/tests/unit/CoreParagraphTest.php @@ -45,36 +45,49 @@ public function tearDown(): void { */ public function query(): string { return ' - fragment CoreParagraphBlockFragment on CoreParagraph { - attributes { - align - anchor - backgroundColor - className - content - cssClassName - dropCap - direction - fontFamily - fontSize - gradient - lock - metadata - placeholder - style - textColor - } - } - query Post( $id: ID! ) { - post(id: $id, idType: DATABASE_ID) { - databaseId - editorBlocks { - name - ...CoreParagraphBlockFragment - } - } - } - '; + fragment CoreParagraphBlockFragment on CoreParagraph { + attributes { + align + anchor + backgroundColor + className + content + cssClassName + dropCap + direction + fontFamily + fontSize + gradient + lock + metadata + placeholder + style + textColor + } + } + query Post( $id: ID! ) { + post(id: $id, idType: DATABASE_ID) { + databaseId + editorBlocks { + apiVersion + blockEditorCategoryName + clientId + cssClassNames + innerBlocks { + name + } + isDynamic + name + parentClientId + renderedHtml + ... on BlockWithSupportsAnchor { + anchor + } + ...CoreParagraphBlockFragment + } + } + } + '; } /** @@ -93,10 +106,10 @@ className */ public function test_retrieve_core_paragraph_attributes() { $block_content = ' - -

This is a test paragraph with various attributes.

- - '; + +

This is a test paragraph with various attributes.

+ + '; wp_update_post( [ @@ -105,21 +118,33 @@ public function test_retrieve_core_paragraph_attributes() { ] ); - $actual = graphql( - [ - 'query' => $this->query(), - 'variables' => [ 'id' => $this->post_id ], - ] - ); + $query = $this->query(); + $variables = [ + 'id' => $this->post_id, + ]; - $this->assertArrayNotHasKey( 'errors', $actual ); - $this->assertArrayHasKey( 'data', $actual ); - $this->assertArrayHasKey( 'post', $actual['data'] ); + $actual = graphql( compact( 'query', 'variables' ) ); - $block = $actual['data']['post']['editorBlocks'][0]; - $attributes = $block['attributes']; + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); + $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); + $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); + + $this->assertEquals( $this->post_id, $actual['data']['post']['databaseId'], 'The post ID should match' ); + + $this->assertEquals( 1, count( $actual['data']['post']['editorBlocks'] ) ); - $this->assertEquals( 'core/paragraph', $block['name'] ); + $block = $actual['data']['post']['editorBlocks'][0]; + + $this->assertNotEmpty( $block['apiVersion'], 'The apiVersion should be present' ); + $this->assertEquals( 'text', $block['blockEditorCategoryName'], 'The blockEditorCategoryName should be text' ); + $this->assertNotEmpty( $block['clientId'], 'The clientId should be present' ); + + $this->assertEmpty( $block['innerBlocks'], 'There should be no inner blocks' ); + $this->assertEquals( 'core/paragraph', $block['name'], 'The block name should be core/paragraph' ); + $this->assertEmpty( $block['parentClientId'], 'There should be no parentClientId' ); + $this->assertNotEmpty( $block['renderedHtml'], 'The renderedHtml should be present' ); + + $attributes = $block['attributes']; $this->assertEquals( [ 'align' => 'center', @@ -156,10 +181,10 @@ public function test_retrieve_core_paragraph_attributes() { */ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { $block_content = ' - -

This is a paragraph with drop cap and custom styles.

- - '; + +

This is a paragraph with drop cap and custom styles.

+ + '; wp_update_post( [ @@ -168,16 +193,26 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { ] ); - $actual = graphql( - [ - 'query' => $this->query(), - 'variables' => [ 'id' => $this->post_id ], - ] - ); + $query = $this->query(); + $variables = [ + 'id' => $this->post_id, + ]; - $block = $actual['data']['post']['editorBlocks'][0]; - $attributes = $block['attributes']; + $actual = graphql( compact( 'query', 'variables' ) ); + + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); + $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); + $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); + + $this->assertEquals( $this->post_id, $actual['data']['post']['databaseId'], 'The post ID should match' ); + $this->assertEquals( 1, count( $actual['data']['post']['editorBlocks'] ) ); + + $block = $actual['data']['post']['editorBlocks'][0]; + + $this->assertEquals( 'core/paragraph', $block['name'], 'The block name should be core/paragraph' ); + + $attributes = $block['attributes']; $this->assertEquals( [ 'align' => null, @@ -219,7 +254,7 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { /** * Test retrieval of core/paragraph block with direction and gradient. * - * Attributes covered: + * - Attributes covered: * - align * - direction * - gradient @@ -230,10 +265,10 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { */ public function test_retrieve_core_paragraph_with_direction_and_gradient() { $block_content = ' - -

This is a right-aligned RTL paragraph with a gradient background.

- - '; + +

This is a right-aligned RTL paragraph with a gradient background.

+ + '; wp_update_post( [ @@ -242,16 +277,26 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { ] ); - $actual = graphql( - [ - 'query' => $this->query(), - 'variables' => [ 'id' => $this->post_id ], - ] - ); + $query = $this->query(); + $variables = [ + 'id' => $this->post_id, + ]; - $block = $actual['data']['post']['editorBlocks'][0]; - $attributes = $block['attributes']; + $actual = graphql( compact( 'query', 'variables' ) ); + + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); + $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); + $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); + $this->assertEquals( $this->post_id, $actual['data']['post']['databaseId'], 'The post ID should match' ); + + $this->assertEquals( 1, count( $actual['data']['post']['editorBlocks'] ) ); + + $block = $actual['data']['post']['editorBlocks'][0]; + + $this->assertEquals( 'core/paragraph', $block['name'], 'The block name should be core/paragraph' ); + + $attributes = $block['attributes']; $this->assertEquals( [ 'align' => 'right', @@ -289,10 +334,10 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { */ public function test_retrieve_core_paragraph_with_additional_attributes() { $block_content = ' - -

This is a paragraph with additional attributes.

- - '; + +

This is a paragraph with additional attributes.

+ + '; wp_update_post( [ @@ -301,16 +346,26 @@ public function test_retrieve_core_paragraph_with_additional_attributes() { ] ); - $actual = graphql( - [ - 'query' => $this->query(), - 'variables' => [ 'id' => $this->post_id ], - ] - ); + $query = $this->query(); + $variables = [ + 'id' => $this->post_id, + ]; - $block = $actual['data']['post']['editorBlocks'][0]; - $attributes = $block['attributes']; + $actual = graphql( compact( 'query', 'variables' ) ); + + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); + $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); + $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); + $this->assertEquals( $this->post_id, $actual['data']['post']['databaseId'], 'The post ID should match' ); + + $this->assertEquals( 1, count( $actual['data']['post']['editorBlocks'] ) ); + + $block = $actual['data']['post']['editorBlocks'][0]; + + $this->assertEquals( 'core/paragraph', $block['name'], 'The block name should be core/paragraph' ); + + $attributes = $block['attributes']; $this->assertEquals( [ 'align' => null, From a5c7b5d1e4d9b78361501f902caea76c8b8d9320 Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 17:11:52 +0530 Subject: [PATCH 4/7] temp: log breaks --- tests/unit/CoreParagraphTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php index d3aa169e..26bfc3fc 100644 --- a/tests/unit/CoreParagraphTest.php +++ b/tests/unit/CoreParagraphTest.php @@ -199,6 +199,7 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { ]; $actual = graphql( compact( 'query', 'variables' ) ); + error_log( print_r( $actual, true ) ); $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); From fbd91cc6e810d0dd78aa70376f704c195fadb153 Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 17:17:54 +0530 Subject: [PATCH 5/7] fix: Remove the key 'errors' from array --- tests/unit/CoreParagraphTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php index 26bfc3fc..7386edef 100644 --- a/tests/unit/CoreParagraphTest.php +++ b/tests/unit/CoreParagraphTest.php @@ -125,7 +125,6 @@ public function test_retrieve_core_paragraph_attributes() { $actual = graphql( compact( 'query', 'variables' ) ); - $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -199,9 +198,7 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { ]; $actual = graphql( compact( 'query', 'variables' ) ); - error_log( print_r( $actual, true ) ); - $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -285,7 +282,6 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { $actual = graphql( compact( 'query', 'variables' ) ); - $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -354,7 +350,6 @@ public function test_retrieve_core_paragraph_with_additional_attributes() { $actual = graphql( compact( 'query', 'variables' ) ); - $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); From 01d6e255e40f9588f4a710195889056ebb5542e6 Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Tue, 24 Sep 2024 23:53:57 +0530 Subject: [PATCH 6/7] fix: add previously untested inline comment --- tests/unit/CoreParagraphTest.php | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php index 7386edef..44afa544 100644 --- a/tests/unit/CoreParagraphTest.php +++ b/tests/unit/CoreParagraphTest.php @@ -59,7 +59,7 @@ className fontSize gradient lock - metadata + # metadata placeholder style textColor @@ -125,6 +125,7 @@ public function test_retrieve_core_paragraph_attributes() { $actual = graphql( compact( 'query', 'variables' ) ); + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -146,22 +147,21 @@ public function test_retrieve_core_paragraph_attributes() { $attributes = $block['attributes']; $this->assertEquals( [ - 'align' => 'center', + 'align' => 'center', // previously untested 'anchor' => null, - 'backgroundColor' => 'pale-cyan-blue', + 'backgroundColor' => 'pale-cyan-blue', // previously untested 'className' => null, - 'content' => 'This is a test paragraph with various attributes.', - 'cssClassName' => 'has-text-align-center has-vivid-red-color has-pale-cyan-blue-background-color has-text-color has-background has-large-font-size has-helvetica-arial-font-family', + 'content' => 'This is a test paragraph with various attributes.', // previously untested + 'cssClassName' => 'has-text-align-center has-vivid-red-color has-pale-cyan-blue-background-color has-text-color has-background has-large-font-size has-helvetica-arial-font-family', // previously untested 'dropCap' => false, 'direction' => null, - 'fontFamily' => 'helvetica-arial', - 'fontSize' => 'large', + 'fontFamily' => 'helvetica-arial', // previously untested + 'fontSize' => 'large', // previously untested 'gradient' => null, 'lock' => null, - 'metadata' => null, 'placeholder' => null, 'style' => null, - 'textColor' => 'vivid-red', + 'textColor' => 'vivid-red', // previously untested ], $attributes ); @@ -199,6 +199,7 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { $actual = graphql( compact( 'query', 'variables' ) ); + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -219,15 +220,14 @@ public function test_retrieve_core_paragraph_with_drop_cap_and_custom_styles() { 'className' => null, 'content' => 'This is a paragraph with drop cap and custom styles.', 'cssClassName' => 'has-drop-cap', - 'dropCap' => true, + 'dropCap' => true, // previously untested 'direction' => null, 'fontFamily' => null, 'fontSize' => null, 'gradient' => null, 'lock' => null, - 'metadata' => null, 'placeholder' => null, - 'style' => wp_json_encode( + 'style' => wp_json_encode( // previously untested [ 'typography' => [ 'lineHeight' => '2', @@ -282,6 +282,7 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { $actual = graphql( compact( 'query', 'variables' ) ); + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -303,12 +304,11 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { 'content' => 'This is a right-aligned RTL paragraph with a gradient background.', 'cssClassName' => 'has-text-align-right has-vivid-cyan-blue-to-vivid-purple-gradient-background', 'dropCap' => false, - 'direction' => 'rtl', + 'direction' => 'rtl', // previously untested 'fontFamily' => null, 'fontSize' => null, - 'gradient' => 'vivid-cyan-blue-to-vivid-purple', + 'gradient' => 'vivid-cyan-blue-to-vivid-purple', // previously untested 'lock' => null, - 'metadata' => null, 'placeholder' => null, 'style' => null, 'textColor' => null, @@ -350,6 +350,7 @@ public function test_retrieve_core_paragraph_with_additional_attributes() { $actual = graphql( compact( 'query', 'variables' ) ); + $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); @@ -365,9 +366,9 @@ public function test_retrieve_core_paragraph_with_additional_attributes() { $this->assertEquals( [ 'align' => null, - 'anchor' => 'test-anchor', + 'anchor' => 'test-anchor', // previously untested 'backgroundColor' => null, - 'className' => 'custom-class', + 'className' => 'custom-class', // previously untested 'content' => 'This is a paragraph with additional attributes.', 'cssClassName' => 'custom-class', 'dropCap' => false, @@ -375,9 +376,8 @@ public function test_retrieve_core_paragraph_with_additional_attributes() { 'fontFamily' => null, 'fontSize' => null, 'gradient' => null, - 'lock' => '{"move":true,"remove":true}', - 'metadata' => '{"someKey":"someValue"}', - 'placeholder' => 'Type here...', + 'lock' => '{"move":true,"remove":true}', // previously untested + 'placeholder' => 'Type here...', // previously untested 'style' => null, 'textColor' => null, ], From da41ae06424c542ecd963662157fb8ff3d67a536 Mon Sep 17 00:00:00 2001 From: Ashutosh Gautam Date: Wed, 25 Sep 2024 00:16:04 +0530 Subject: [PATCH 7/7] docs: fix doc-blocks --- tests/unit/CoreParagraphTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/CoreParagraphTest.php b/tests/unit/CoreParagraphTest.php index 44afa544..07420144 100644 --- a/tests/unit/CoreParagraphTest.php +++ b/tests/unit/CoreParagraphTest.php @@ -324,7 +324,6 @@ public function test_retrieve_core_paragraph_with_direction_and_gradient() { * - anchor * - className * - lock - * - metadata * - placeholder * * @return void