From c388771f5890c427a77e42525c84ac807626ea0a Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 10 Sep 2024 08:56:47 +0200 Subject: [PATCH] OP-515: Spec fixes --- .../HeadingContentElementRendererSpec.php | 19 +++++++------------ ...ultipleMediaContentElementRendererSpec.php | 17 ++++++++--------- ...esCollectionContentElementRendererSpec.php | 17 +++++++++-------- ...ouselByTaxonContentElementRendererSpec.php | 18 +++++++++--------- ...uctsCarouselContentElementRendererSpec.php | 18 +++++++++--------- ...sGridByTaxonContentElementRendererSpec.php | 18 +++++++++--------- ...ProductsGridContentElementRendererSpec.php | 18 +++++++++--------- .../SingleMediaContentElementRendererSpec.php | 18 +++++++++--------- .../SpacerContentElementRendererSpec.php | 19 +++++++------------ .../TaxonsListContentElementRendererSpec.php | 18 +++++++++--------- .../TextareaContentElementRendererSpec.php | 19 +++++++------------ 11 files changed, 92 insertions(+), 107 deletions(-) diff --git a/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php b/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php index 2050bc4c..63e3d71c 100644 --- a/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php @@ -7,25 +7,16 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\HeadingContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\HeadingContentElementRenderer; use Twig\Environment; final class HeadingContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig): void - { - $this->beConstructedWith($twig); - } - public function it_is_initializable(): void { $this->shouldHaveType(HeadingContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_heading_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -42,13 +33,17 @@ public function it_does_not_support_other_content_element_types(ContentConfigura public function it_renders_heading_content_element(Environment $twig, ContentConfigurationInterface $contentConfiguration): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'heading_type' => 'h1', 'heading' => 'Sample Heading', ]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_heading.html.twig', + 'content_element' => $template, 'heading_type' => 'h1', 'heading_content' => 'Sample Heading', ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php b/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php index f9549ed1..bbfae8d2 100644 --- a/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php @@ -8,7 +8,7 @@ use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Entity\MediaInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\MultipleMediaContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\MultipleMediaContentElementRenderer; use Sylius\CmsPlugin\Repository\MediaRepositoryInterface; use Sylius\CmsPlugin\Twig\Runtime\RenderMediaRuntimeInterface; @@ -17,21 +17,16 @@ final class MultipleMediaContentElementRendererSpec extends ObjectBehavior { public function let( - Environment $twig, RenderMediaRuntimeInterface $renderMediaRuntime, MediaRepositoryInterface $mediaRepository, ): void { - $this->beConstructedWith($twig, $renderMediaRuntime, $mediaRepository); + $this->beConstructedWith($renderMediaRuntime, $mediaRepository); } public function it_is_initializable(): void { $this->shouldHaveType(MultipleMediaContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_multiple_media_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -54,6 +49,10 @@ public function it_renders_multiple_media_content_element( MediaInterface $media1, MediaInterface $media2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'multiple_media' => ['code1', 'code2'], ]); @@ -67,7 +66,7 @@ public function it_renders_multiple_media_content_element( $renderMediaRuntime->renderMedia('code2')->willReturn('rendered media 2'); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_multiple_media.html.twig', + 'content_element' => $template, 'media' => [ [ 'renderedContent' => 'rendered media 1', diff --git a/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php b/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php index 17909029..97a5966c 100644 --- a/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php @@ -9,6 +9,7 @@ use Sylius\CmsPlugin\Entity\CollectionInterface; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\PagesCollectionContentElementType; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; use Sylius\CmsPlugin\Renderer\ContentElement\PagesCollectionContentElementRenderer; use Sylius\CmsPlugin\Repository\CollectionRepositoryInterface; @@ -16,19 +17,15 @@ final class PagesCollectionContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, CollectionRepositoryInterface $collectionRepository): void + public function let(CollectionRepositoryInterface $collectionRepository): void { - $this->beConstructedWith($twig, $collectionRepository); + $this->beConstructedWith($collectionRepository); } public function it_is_initializable(): void { $this->shouldHaveType(PagesCollectionContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_pages_collection_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -49,6 +46,10 @@ public function it_renders_pages_collection_content_element( ContentConfigurationInterface $contentConfiguration, CollectionInterface $collection, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'pages_collection' => 'collection_code', ]); @@ -59,7 +60,7 @@ public function it_renders_pages_collection_content_element( $collection->getPages()->willReturn($pagesCollection); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_pages_collection.html.twig', + 'content_element' => $template, 'collection' => $pagesCollection, ])->willReturn('rendered_output'); diff --git a/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php index 9b106e50..b79c1ff6 100644 --- a/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\ProductsCarouselByTaxonContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\ProductsCarouselByTaxonContentElementRenderer; use Sylius\Component\Core\Model\Product; use Sylius\Component\Core\Model\TaxonInterface; @@ -17,19 +17,15 @@ final class ProductsCarouselByTaxonContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, ProductRepositoryInterface $productRepository, TaxonRepositoryInterface $taxonRepository): void + public function let(ProductRepositoryInterface $productRepository, TaxonRepositoryInterface $taxonRepository): void { - $this->beConstructedWith($twig, $productRepository, $taxonRepository); + $this->beConstructedWith($productRepository, $taxonRepository); } public function it_is_initializable(): void { $this->shouldHaveType(ProductsCarouselByTaxonContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_products_carousel_by_taxon_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -53,6 +49,10 @@ public function it_renders_products_carousel_by_taxon_content_element( Product $product1, Product $product2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'products_carousel_by_taxon' => 'taxon_code', ]); @@ -61,7 +61,7 @@ public function it_renders_products_carousel_by_taxon_content_element( $productRepository->findByTaxon($taxon)->willReturn([$product1, $product2]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_products_carousel.html.twig', + 'content_element' => $template, 'products' => [$product1, $product2], ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php index ac665426..91a25d74 100644 --- a/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\ProductsCarouselContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\ProductsCarouselContentElementRenderer; use Sylius\Component\Core\Model\Product; use Sylius\Component\Core\Repository\ProductRepositoryInterface; @@ -15,19 +15,15 @@ final class ProductsCarouselContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, ProductRepositoryInterface $productRepository): void + public function let(ProductRepositoryInterface $productRepository): void { - $this->beConstructedWith($twig, $productRepository); + $this->beConstructedWith($productRepository); } public function it_is_initializable(): void { $this->shouldHaveType(ProductsCarouselContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_products_carousel_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -49,6 +45,10 @@ public function it_renders_products_carousel_content_element( Product $product1, Product $product2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'products_carousel' => ['products' => ['code1', 'code2']], ]); @@ -56,7 +56,7 @@ public function it_renders_products_carousel_content_element( $productRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$product1, $product2]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_products_carousel.html.twig', + 'content_element' => $template, 'products' => [$product1, $product2], ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php index b8d388b3..000108a5 100644 --- a/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\ProductsGridByTaxonContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\ProductsGridByTaxonContentElementRenderer; use Sylius\Component\Core\Model\Product; use Sylius\Component\Core\Model\TaxonInterface; @@ -17,19 +17,15 @@ final class ProductsGridByTaxonContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, ProductRepositoryInterface $productRepository, TaxonRepositoryInterface $taxonRepository): void + public function let(ProductRepositoryInterface $productRepository, TaxonRepositoryInterface $taxonRepository): void { - $this->beConstructedWith($twig, $productRepository, $taxonRepository); + $this->beConstructedWith($productRepository, $taxonRepository); } public function it_is_initializable(): void { $this->shouldHaveType(ProductsGridByTaxonContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_products_grid_by_taxon_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -53,6 +49,10 @@ public function it_renders_products_grid_by_taxon_content_element( Product $product1, Product $product2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'products_grid_by_taxon' => 'taxon_code', ]); @@ -61,7 +61,7 @@ public function it_renders_products_grid_by_taxon_content_element( $productRepository->findByTaxon($taxon)->willReturn([$product1, $product2]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'content_element' => $template, 'products' => [$product1, $product2], ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php index d093c2d3..0c237bd4 100644 --- a/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\ProductsGridContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\ProductsGridContentElementRenderer; use Sylius\Component\Core\Model\Product; use Sylius\Component\Core\Repository\ProductRepositoryInterface; @@ -15,19 +15,15 @@ final class ProductsGridContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, ProductRepositoryInterface $productRepository): void + public function let(ProductRepositoryInterface $productRepository): void { - $this->beConstructedWith($twig, $productRepository); + $this->beConstructedWith($productRepository); } public function it_is_initializable(): void { $this->shouldHaveType(ProductsGridContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_products_grid_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -49,6 +45,10 @@ public function it_renders_products_grid_content_element( Product $product1, Product $product2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'products_grid' => ['products' => ['code1', 'code2']], ]); @@ -56,7 +56,7 @@ public function it_renders_products_grid_content_element( $productRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$product1, $product2]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'content_element' => $template, 'products' => [$product1, $product2], ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php b/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php index 28e18edc..d9a08cc2 100644 --- a/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php @@ -8,7 +8,7 @@ use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Entity\MediaInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\SingleMediaContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\SingleMediaContentElementRenderer; use Sylius\CmsPlugin\Repository\MediaRepositoryInterface; use Sylius\CmsPlugin\Twig\Runtime\RenderMediaRuntimeInterface; @@ -16,19 +16,15 @@ final class SingleMediaContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, RenderMediaRuntimeInterface $renderMediaRuntime, MediaRepositoryInterface $mediaRepository): void + public function let(RenderMediaRuntimeInterface $renderMediaRuntime, MediaRepositoryInterface $mediaRepository): void { - $this->beConstructedWith($twig, $renderMediaRuntime, $mediaRepository); + $this->beConstructedWith($renderMediaRuntime, $mediaRepository); } public function it_is_initializable(): void { $this->shouldHaveType(SingleMediaContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_single_media_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -50,6 +46,10 @@ public function it_renders_single_media_content_element( ContentConfigurationInterface $contentConfiguration, MediaInterface $media, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'single_media' => 'media_code', ]); @@ -58,7 +58,7 @@ public function it_renders_single_media_content_element( $mediaRepository->findOneBy(['code' => 'media_code'])->willReturn($media); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_single_media.html.twig', + 'content_element' => $template, 'media' => [ 'renderedContent' => 'rendered media', 'entity' => $media, diff --git a/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php b/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php index a7972e21..79c8acc4 100644 --- a/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php @@ -7,25 +7,16 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\SpacerContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\SpacerContentElementRenderer; use Twig\Environment; final class SpacerContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig): void - { - $this->beConstructedWith($twig); - } - public function it_is_initializable(): void { $this->shouldHaveType(SpacerContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_spacer_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -42,12 +33,16 @@ public function it_does_not_support_other_content_element_types(ContentConfigura public function it_renders_spacer_content_element(Environment $twig, ContentConfigurationInterface $contentConfiguration): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'spacer' => '40', ]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_spacer.html.twig', + 'content_element' => $template, 'spacer_height' => '40', ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php b/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php index 3fc7cc17..96fd44ea 100644 --- a/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\TaxonsListContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\TaxonsListContentElementRenderer; use Sylius\Component\Core\Model\Taxon; use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface; @@ -15,19 +15,15 @@ final class TaxonsListContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig, TaxonRepositoryInterface $taxonRepository): void + public function let(TaxonRepositoryInterface $taxonRepository): void { - $this->beConstructedWith($twig, $taxonRepository); + $this->beConstructedWith($taxonRepository); } public function it_is_initializable(): void { $this->shouldHaveType(TaxonsListContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_taxons_list_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -49,6 +45,10 @@ public function it_renders_taxons_list_content_element( Taxon $taxon1, Taxon $taxon2, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'taxons_list' => ['taxons' => ['code1', 'code2']], ]); @@ -56,7 +56,7 @@ public function it_renders_taxons_list_content_element( $taxonRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$taxon1, $taxon2]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_taxons_list.html.twig', + 'content_element' => $template, 'taxons' => [$taxon1, $taxon2], ])->willReturn('rendered template'); diff --git a/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php b/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php index ef584485..208ae280 100644 --- a/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php +++ b/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php @@ -7,25 +7,16 @@ use PhpSpec\ObjectBehavior; use Sylius\CmsPlugin\Entity\ContentConfigurationInterface; use Sylius\CmsPlugin\Form\Type\ContentElements\TextareaContentElementType; -use Sylius\CmsPlugin\Renderer\ContentElement\ContentElementRendererInterface; +use Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement; use Sylius\CmsPlugin\Renderer\ContentElement\TextareaContentElementRenderer; use Twig\Environment; final class TextareaContentElementRendererSpec extends ObjectBehavior { - public function let(Environment $twig): void - { - $this->beConstructedWith($twig); - } - public function it_is_initializable(): void { $this->shouldHaveType(TextareaContentElementRenderer::class); - } - - public function it_implements_content_element_renderer_interface(): void - { - $this->shouldImplement(ContentElementRendererInterface::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); } public function it_supports_textarea_content_element_type(ContentConfigurationInterface $contentConfiguration): void @@ -44,12 +35,16 @@ public function it_renders_textarea_content_element( Environment $twig, ContentConfigurationInterface $contentConfiguration, ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + $contentConfiguration->getConfiguration()->willReturn([ 'textarea' => 'Textarea content', ]); $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ - 'content_element' => '@SyliusCmsPlugin/Shop/ContentElement/_textarea.html.twig', + 'content_element' => $template, 'content' => 'Textarea content', ])->willReturn('rendered template');