diff --git a/tests/Transformers/BardTransformerTest.php b/tests/Transformers/BardTransformerTest.php index ebc061a..03f6b05 100644 --- a/tests/Transformers/BardTransformerTest.php +++ b/tests/Transformers/BardTransformerTest.php @@ -158,7 +158,7 @@ public function it_doesnt_handles_images_without_base_url() } #[Test] - public function is_enables_buttons_on_bard_field() + public function it_enables_buttons_on_bard_field() { $transformer = new BardTransformer( import: $this->import, @@ -192,10 +192,60 @@ public function is_enables_buttons_on_bard_field() } #[Test] - public function is_enables_buttons_on_bard_field_in_fieldset() + public function it_enables_buttons_on_imported_bard_field() { Fieldset::make('content_stuff')->setContents(['fields' => [ - ['handle' => 'bard_basic', 'field' => ['type' => 'bard']], + ['handle' => 'bard_field', 'field' => ['type' => 'bard']], + ]])->save(); + + $blueprint = $this->collection->entryBlueprint(); + + $this->blueprint->setContents([ + 'sections' => [ + 'main' => [ + 'fields' => [ + ['handle' => 'bard_field', 'field' => 'content_stuff.bard_field'], + ], + ], + ], + ])->save(); + + $transformer = new BardTransformer( + import: $this->import, + blueprint: $blueprint, + field: $blueprint->field('bard_field'), + config: [] + ); + + $transformer->transform('
Hello world!
'); + + $fieldset = Fieldset::find('content_stuff'); + + $this->assertEquals([ + 'h1', + 'h2', + 'h3', + 'bold', + 'italic', + 'unorderedlist', + 'orderedlist', + 'removeformat', + 'quote', + 'anchor', + 'image', + 'table', + 'horizontalrule', + 'codeblock', + 'underline', + 'superscript', + ], $fieldset->field('bard_field')->get('buttons')); + } + + #[Test] + public function it_enables_buttons_on_imported_bard_field_with_prefix() + { + Fieldset::make('content_stuff')->setContents(['fields' => [ + ['handle' => 'bard_field', 'field' => ['type' => 'bard']], ]])->save(); $blueprint = $this->collection->entryBlueprint(); @@ -213,7 +263,7 @@ public function is_enables_buttons_on_bard_field_in_fieldset() $transformer = new BardTransformer( import: $this->import, blueprint: $blueprint, - field: $blueprint->field('resources_bard_basic'), + field: $blueprint->field('resources_bard_field'), config: [] ); @@ -238,6 +288,6 @@ public function is_enables_buttons_on_bard_field_in_fieldset() 'codeblock', 'underline', 'superscript', - ], $fieldset->field('bard_basic')->get('buttons')); + ], $fieldset->field('bard_field')->get('buttons')); } } diff --git a/tests/WordPress/GutenbergTest.php b/tests/WordPress/GutenbergTest.php index 8afa50a..129c122 100644 --- a/tests/WordPress/GutenbergTest.php +++ b/tests/WordPress/GutenbergTest.php @@ -769,10 +769,43 @@ public function it_transforms_spacer_blocks() } #[Test] - public function it_append_sets_to_bard_field_in_fieldset() + public function it_append_sets_to_imported_bard_field() { Fieldset::make('content_stuff')->setContents(['fields' => [ - ['handle' => 'bard_basic', 'field' => ['type' => 'bard']], + ['handle' => 'bard_field', 'field' => ['type' => 'bard']], + ]])->save(); + + $this->blueprint->setContents([ + 'sections' => [ + 'main' => [ + 'fields' => [ + ['handle' => 'bard_field', 'field' => 'content_stuff.bard_field'], + ], + ], + ], + ])->save(); + + Gutenberg::toBard( + config: [], + blueprint: $this->blueprint, + field: $this->blueprint->field('bard_field'), + value: <<<'HTML' + + + +HTML + ); + + $fieldset = Fieldset::find('content_stuff'); + + $this->assertSetExists('spacer', $fieldset->field('bard_field')); + } + + #[Test] + public function it_append_sets_to_imported_bard_field_with_prefix() + { + Fieldset::make('content_stuff')->setContents(['fields' => [ + ['handle' => 'bard_field', 'field' => ['type' => 'bard']], ]])->save(); $this->blueprint->setContents([ @@ -788,7 +821,7 @@ public function it_append_sets_to_bard_field_in_fieldset() Gutenberg::toBard( config: [], blueprint: $this->blueprint, - field: $this->blueprint->field('resources_bard_basic'), + field: $this->blueprint->field('resources_bard_field'), value: <<<'HTML' @@ -798,7 +831,7 @@ public function it_append_sets_to_bard_field_in_fieldset() $fieldset = Fieldset::find('content_stuff'); - $this->assertSetExists('spacer', $fieldset->field('bard_basic')); + $this->assertSetExists('spacer', $fieldset->field('bard_field')); } #[Test]