diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature
index d825b765c..16c30b203 100644
--- a/features/admin/adding_block.feature
+++ b/features/admin/adding_block.feature
@@ -9,37 +9,19 @@ Feature: Adding blocks
And the store operates on a single channel in "United States"
@ui
- Scenario: Adding html block
- When I go to the create "html" block page
+ Scenario: Adding block
+ When I go to the create block page
And I fill the code with "store_description"
And I fill the content with "
We have the best candies on the internet!
"
And I add it
Then I should be notified that the block has been created
- @ui
- Scenario: Adding text block
- When I go to the create "text" block page
- And I fill the code with "store_main_title"
- And I fill the name with "Store title"
- And I fill the content with "Welcome to the Candy Shop"
- And I add it
- Then I should be notified that the block has been created
-
- @ui
- Scenario: Adding image block
- When I go to the create "image" block page
- And I fill the code with "aston_martin_db_11"
- And I fill the name with "Aston Marting DB 11 image"
- And I fill the link with "/page/aston-martin-db-11-review"
- And I upload the "aston_martin_db_11.jpg" image
- And I add it
- Then I should be notified that the block has been created
-
@ui @javascript
Scenario: Adding block with sections
Given there are existing sections named "Blog" and "Homepage"
- When I go to the create "html" block page
- And I fill "Code, Content" fields
+ When I go to the create block page
+ And I fill the code with "intro"
+ And I fill the content with "Hello world!"
And I add "Blog" and "Homepage" sections to it
And I add it
Then I should be notified that the block has been created
@@ -47,46 +29,33 @@ Feature: Adding blocks
@ui
Scenario: Trying to add block with existing code
Given there is an existing block with "homepage_image" code
- When I go to the create "text" block page
+ When I go to the create block page
And I fill the code with "homepage_image"
And I try to add it
Then I should be notified that there is already an existing block with provided code
@ui
- Scenario: Trying to add text block with blank data
- When I go to the create "text" block page
+ Scenario: Trying to add block with blank data
+ When I go to the create block page
And I try to add it
Then I should be notified that "Code, Content" fields cannot be blank
@ui
- Scenario: Trying to add html block with blank data
- When I go to the create "html" block page
+ Scenario: Trying to add block with blank data
+ When I go to the create block page
And I try to add it
Then I should be notified that "Code, Content" fields cannot be blank
@ui
- Scenario: Trying to add image block with blank data
- When I go to the create "image" block page
- And I try to add it
- Then I should be notified that "Code, Image" fields cannot be blank
-
- @ui
- Scenario: Trying to add text block with too long data
- When I go to the create "text" block page
+ Scenario: Trying to add block with too long data
+ When I go to the create block page
And I fill "Code, Name, Content" fields with 6000 characters
And I try to add it
Then I should be notified that "Code, Name" fields are too long
@ui
- Scenario: Trying to add html block with too long data
- When I go to the create "html" block page
+ Scenario: Trying to add block with too long data
+ When I go to the create block page
And I fill "Code, Name, Content" fields with 6000 characters
And I try to add it
Then I should be notified that "Code, Name" fields are too long
-
- @ui
- Scenario: Trying to add image block with too long data
- When I go to the create "image" block page
- And I fill "Code, Name" fields with 6000 characters
- And I try to add it
- Then I should be notified that "Code, Name" fields are too long
diff --git a/features/admin/managing_blocks.feature b/features/admin/managing_blocks.feature
index 1cc1eb338..54b703046 100644
--- a/features/admin/managing_blocks.feature
+++ b/features/admin/managing_blocks.feature
@@ -17,8 +17,8 @@ Feature: Managing cms blocks
And I should see empty list of blocks
@ui
- Scenario: Updating text block
- Given there is a text block with "store_phone_number" code and "123456789" content
+ Scenario: Updating block
+ Given there is a block with "store_phone_number" code and "123456789" content
When I go to the update "store_phone_number" block page
And I fill the content with "987654321"
And I update it
@@ -26,20 +26,12 @@ Feature: Managing cms blocks
@ui
Scenario: Updating html block
- Given there is a html block with "store_email" code and "mikolaj.krol@bitbag.pl" content
+ Given there is a block with "store_email" code and "mikolaj.krol@bitbag.pl" content
When I go to the update "store_email" block page
And I fill the content with "mikolaj.krol@bitbag.pl"
And I update it
Then I should be notified that the block has been successfully updated
- @ui
- Scenario: Updating image block
- Given there is an existing block with "porsche_911_singer" code and "porsche_911_singer_1.jpg" image
- When I go to the update "porsche_911_singer" block page
- And I upload the "porsche_911_singer_2.jpg" image
- And I update it
- Then I should be notified that the block has been successfully updated
-
@ui
Scenario: Disabling block
Given there is an existing block with "bitbag_quote" code
@@ -54,8 +46,3 @@ Feature: Managing cms blocks
Given there is a block in the store
When I want to edit this block
Then the code field should be disabled
-
- @ui
- Scenario: Being able to chose which block type to create
- When I go to the blocks page
- Then I should be able to select between "Text block", "HTML block" and "Image block" block types under Create button
diff --git a/spec/Entity/BlockImageSpec.php b/spec/Entity/BlockImageSpec.php
deleted file mode 100755
index 054bbb5af..000000000
--- a/spec/Entity/BlockImageSpec.php
+++ /dev/null
@@ -1,30 +0,0 @@
-shouldHaveType(BlockImage::class);
- }
-
- function it_extends_sylius_image(): void
- {
- $this->shouldHaveType(SyliusImage::class);
- }
-}
diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php
index 8c4db8d70..1183d3141 100755
--- a/spec/Entity/BlockSpec.php
+++ b/spec/Entity/BlockSpec.php
@@ -37,18 +37,6 @@ function it_implements_block_interface(): void
$this->shouldHaveType(BlockInterface::class);
}
- function it_allows_access_via_properties(): void
- {
- $this->setType('image');
- $this->getType()->shouldReturn('image');
-
- $this->setType('new_focus_rs');
- $this->getType()->shouldReturn('new_focus_rs');
-
- $this->setEnabled(true);
- $this->isEnabled()->shouldReturn(true);
- }
-
function it_toggles(): void
{
$this->enable();
diff --git a/spec/Entity/BlockTranslationSpec.php b/spec/Entity/BlockTranslationSpec.php
index 472bf8f8f..92106c812 100755
--- a/spec/Entity/BlockTranslationSpec.php
+++ b/spec/Entity/BlockTranslationSpec.php
@@ -12,7 +12,6 @@
namespace spec\BitBag\SyliusCmsPlugin\Entity;
-use BitBag\SyliusCmsPlugin\Entity\BlockImageInterface;
use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Resource\Model\ResourceInterface;
@@ -36,15 +35,12 @@ function it_implements_block_translation_interface(): void
$this->shouldHaveType(TranslationInterface::class);
}
- function it_allows_access_via_properties(BlockImageInterface $blockImage): void
+ function it_allows_access_via_properties(): void
{
$this->setName('Escobar favorite quote');
$this->getName()->shouldReturn('Escobar favorite quote');
$this->setContent('Plata o plomo');
$this->getContent()->shouldReturn('Plata o plomo');
-
- $this->setImage($blockImage);
- $this->getImage()->shouldReturn($blockImage);
}
}
diff --git a/spec/EventListener/BlockImageUploadListenerSpec.php b/spec/EventListener/BlockImageUploadListenerSpec.php
deleted file mode 100755
index 5f5511e77..000000000
--- a/spec/EventListener/BlockImageUploadListenerSpec.php
+++ /dev/null
@@ -1,72 +0,0 @@
-beConstructedWith($blockImageUploader);
- }
-
- function it_is_initializable(): void
- {
- $this->shouldHaveType(BlockImageUploadListener::class);
- }
-
- function it_does_not_upload_if_not_block_instance(
- ResourceControllerEvent $event,
- BlockInterface $block
- ): void {
- $event->getSubject()->willReturn(Argument::any());
-
- $block->getType()->shouldNotBeCalled();
- }
-
- function it_does_not_upload_if_not_image_Block(
- ResourceControllerEvent $event,
- BlockInterface $block
- ): void {
- $event->getSubject()->willReturn($block);
- $block->getType()->willReturn(Argument::any());
-
- $block->getTranslations()->shouldNotBeCalled();
- }
-
- function it_upload_image_for_each_translations(
- ResourceControllerEvent $event,
- BlockInterface $block,
- BlockTranslationInterface $blockTranslation,
- BlockImageInterface $blockImage,
- ImageUploaderInterface $blockImageUploader
- ): void {
- $event->getSubject()->willReturn($block);
- $block->getType()->willReturn('image');
- $block->getTranslations()->willReturn(new ArrayCollection([$blockTranslation->getWrappedObject()]));
- $blockTranslation->getImage()->willReturn($blockImage);
- $blockImage->hasFile()->willReturn(true);
-
- $blockImageUploader->upload($blockImage)->shouldBeCalled();
- $this->uploadImage($event);
- }
-}
diff --git a/spec/Exception/TemplateTypeNotFoundSpec.php b/spec/Exception/TemplateTypeNotFoundSpec.php
deleted file mode 100755
index 84470533a..000000000
--- a/spec/Exception/TemplateTypeNotFoundSpec.php
+++ /dev/null
@@ -1,39 +0,0 @@
-beConstructedWith('bitbag');
- }
-
- function it_is_initializable(): void
- {
- $this->shouldHaveType(TemplateTypeNotFound::class);
- }
-
- function it_is_an_exception(): void
- {
- $this->shouldHaveType(\Exception::class);
- }
-
- function it_has_custom_message(): void
- {
- $this->getMessage()->shouldReturn('Template type "bitbag" was not found.');
- }
-}
diff --git a/spec/Factory/BlockFactorySpec.php b/spec/Factory/BlockFactorySpec.php
deleted file mode 100755
index 74c592ca1..000000000
--- a/spec/Factory/BlockFactorySpec.php
+++ /dev/null
@@ -1,50 +0,0 @@
-beConstructedWith($resourceFactory);
- }
-
- function it_is_initializable(): void
- {
- $this->shouldHaveType(BlockFactory::class);
- }
-
- function it_creates_new_block(
- FactoryInterface $resourceFactory,
- BlockInterface $block
- ): void {
- $resourceFactory->createNew()->willReturn($block);
-
- $this->createNew()->shouldBeEqualTo($block);
- }
-
- function it_creates_new_block_with_type(
- FactoryInterface $resourceFactory,
- BlockInterface $block
- ): void {
- $resourceFactory->createNew()->willReturn($block);
- $block->setType('image')->shouldBeCalled();
-
- $this->createWithType('image')->shouldBeEqualTo($block);
- }
-}
diff --git a/spec/Resolver/BlockTemplateResolverSpec.php b/spec/Resolver/BlockTemplateResolverSpec.php
deleted file mode 100755
index 8c0418c61..000000000
--- a/spec/Resolver/BlockTemplateResolverSpec.php
+++ /dev/null
@@ -1,52 +0,0 @@
-shouldHaveType(BlockTemplateResolver::class);
- }
-
- function it_implements_block_template_resolver_interface()
- {
- $this->shouldHaveType(BlockTemplateResolverInterface::class);
- }
-
- function it_returns_text_block_template(BlockInterface $block)
- {
- $block->getType()->willReturn('text');
-
- $this->resolveTemplate($block)->shouldReturn('@BitBagSyliusCmsPlugin/Shop/Block/Show/textBlock.html.twig');
- }
-
- function it_returns_html_block_template(BlockInterface $block)
- {
- $block->getType()->willReturn('html');
-
- $this->resolveTemplate($block)->shouldReturn('@BitBagSyliusCmsPlugin/Shop/Block/Show/htmlBlock.html.twig');
- }
-
- function it_returns_image_block_template(BlockInterface $block)
- {
- $block->getType()->willReturn('image');
-
- $this->resolveTemplate($block)->shouldReturn('@BitBagSyliusCmsPlugin/Shop/Block/Show/imageBlock.html.twig');
- }
-}
diff --git a/spec/Twig/Extension/RenderBlockExtensionSpec.php b/spec/Twig/Extension/RenderBlockExtensionSpec.php
index 4f833a76b..bc2fc2087 100755
--- a/spec/Twig/Extension/RenderBlockExtensionSpec.php
+++ b/spec/Twig/Extension/RenderBlockExtensionSpec.php
@@ -15,7 +15,6 @@
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use BitBag\SyliusCmsPlugin\Resolver\BlockResourceResolverInterface;
-use BitBag\SyliusCmsPlugin\Resolver\BlockTemplateResolverInterface;
use BitBag\SyliusCmsPlugin\Twig\Extension\RenderBlockExtension;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Templating\EngineInterface;
@@ -24,11 +23,10 @@ final class RenderBlockExtensionSpec extends ObjectBehavior
{
function let(
BlockRepositoryInterface $blockRepository,
- BlockTemplateResolverInterface $blockTemplateResolver,
BlockResourceResolverInterface $blockResourceResolver,
EngineInterface $templatingEngine
): void {
- $this->beConstructedWith($blockRepository, $blockTemplateResolver, $blockResourceResolver, $templatingEngine);
+ $this->beConstructedWith($blockRepository, $blockResourceResolver, $templatingEngine);
}
function it_is_initializable(): void
@@ -54,27 +52,23 @@ function it_returns_functions(): void
function it_renders_block(
BlockResourceResolverInterface $blockResourceResolver,
- BlockTemplateResolverInterface $blockTemplateResolver,
BlockInterface $block,
EngineInterface $templatingEngine
): void {
$blockResourceResolver->findOrLog('bitbag')->willReturn($block);
- $blockTemplateResolver->resolveTemplate($block)->willReturn('@BitBagSyliusCmsPlugin/Shop/Block/htmlBlock.html.twig');
- $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/htmlBlock.html.twig', ['block' => $block])->willReturn('BitBag
');
+ $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig', ['block' => $block])->willReturn('BitBag
');
$this->renderBlock('bitbag');
}
function it_renders_block_with_template(
BlockResourceResolverInterface $blockResourceResolver,
- BlockTemplateResolverInterface $blockTemplateResolver,
BlockInterface $block,
EngineInterface $templatingEngine
): void {
$blockResourceResolver->findOrLog('bitbag')->willReturn($block);
- $blockTemplateResolver->resolveTemplate($block)->shouldNotBeCalled();
- $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/htmlBlock_other_template.html.twig', ['block' => $block])->willReturn('BitBag Other Template
');
+ $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/otherTemplate.html.twig', ['block' => $block])->willReturn('BitBag Other Template
');
- $this->renderBlock('bitbag', '@BitBagSyliusCmsPlugin/Shop/Block/htmlBlock_other_template.html.twig');
+ $this->renderBlock('bitbag', '@BitBagSyliusCmsPlugin/Shop/Block/otherTemplate.html.twig');
}
}
diff --git a/src/Assigner/ChannelsAssigner.php b/src/Assigner/ChannelsAssigner.php
index a4151fc31..6eb4e591a 100644
--- a/src/Assigner/ChannelsAssigner.php
+++ b/src/Assigner/ChannelsAssigner.php
@@ -1,11 +1,11 @@
requestConfigurationFactory->create($this->metadata, $request);
@@ -29,7 +31,6 @@ public function renderBlockAction(Request $request): Response
$code = $request->get('code');
$blockResourceResolver = $this->get('bitbag_sylius_cms_plugin.resolver.block_resource');
-
$block = $blockResourceResolver->findOrLog($code);
if (null === $block) {
@@ -39,8 +40,7 @@ public function renderBlockAction(Request $request): Response
$this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $block);
$view = View::create($block);
- $blockTemplateResolver = $this->get('bitbag_sylius_cms_plugin.resolver.block_template');
- $template = $request->get('template') ?? $blockTemplateResolver->resolveTemplate($block);
+ $template = $request->get('template') ?? self::BLOCK_TEMPLATE;
if ($configuration->isHtmlRequest()) {
$view
@@ -65,9 +65,6 @@ public function previewAction(Request $request): Response
$this->isGrantedOr403($configuration, ResourceActions::CREATE);
/** @var BlockInterface $block */
$block = $this->newResourceFactory->create($configuration, $this->factory);
-
- $block->setType($request->get('type'));
-
$form = $this->resourceFormFactory->create($configuration, $block);
$form->handleRequest($request);
@@ -79,13 +76,11 @@ public function previewAction(Request $request): Response
$block->setFallbackLocale($request->get('_locale', $defaultLocale));
$block->setCurrentLocale($request->get('_locale', $defaultLocale));
- $blockTemplateResolver = $this->get('bitbag_sylius_cms_plugin.resolver.block_template');
-
$view = View::create()
->setData([
'resource' => $block,
$this->metadata->getName() => $block,
- 'blockTemplate' => $blockTemplateResolver->resolveTemplate($block),
+ 'blockTemplate' => self::BLOCK_TEMPLATE,
])
->setTemplate($configuration->getTemplate(ResourceActions::CREATE . '.html'))
;
diff --git a/src/Entity/Block.php b/src/Entity/Block.php
index de6f389d7..7de6c81a6 100755
--- a/src/Entity/Block.php
+++ b/src/Entity/Block.php
@@ -12,7 +12,6 @@
namespace BitBag\SyliusCmsPlugin\Entity;
-use Sylius\Component\Core\Model\ImageInterface;
use Sylius\Component\Resource\Model\ToggleableTrait;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
@@ -41,9 +40,6 @@ public function __construct()
/** @var string */
protected $code;
- /** @var string */
- protected $type;
-
public function getId(): ?int
{
return $this->id;
@@ -59,16 +55,6 @@ public function setCode(?string $code): void
$this->code = $code;
}
- public function getType(): ?string
- {
- return $this->type;
- }
-
- public function setType(?string $type): void
- {
- $this->type = $type;
- }
-
public function getName(): ?string
{
return $this->getBlockTranslation()->getName();
@@ -89,16 +75,6 @@ public function setContent(?string $content): void
$this->getBlockTranslation()->setContent($content);
}
- public function getImage(): ?ImageInterface
- {
- return $this->getBlockTranslation()->getImage();
- }
-
- public function setImage(?ImageInterface $image): void
- {
- $this->getBlockTranslation()->setImage($image);
- }
-
public function getLink(): ?string
{
return $this->getBlockTranslation()->getLink();
diff --git a/src/Entity/BlockImage.php b/src/Entity/BlockImage.php
deleted file mode 100755
index 2b44693b1..000000000
--- a/src/Entity/BlockImage.php
+++ /dev/null
@@ -1,19 +0,0 @@
-id;
}
- public function getImage(): ?BlockImageInterface
- {
- return $this->image;
- }
-
- public function setImage(?BlockImageInterface $image): void
- {
- $image->setOwner($this);
-
- $this->image = $image;
- }
-
public function getLink(): ?string
{
return $this->link;
diff --git a/src/Entity/BlockTranslationInterface.php b/src/Entity/BlockTranslationInterface.php
index 587f00cfa..ee372f05d 100755
--- a/src/Entity/BlockTranslationInterface.php
+++ b/src/Entity/BlockTranslationInterface.php
@@ -25,13 +25,6 @@ public function getContent(): ?string;
public function setContent(?string $content): void;
- /**
- * @return BlockImageInterface|null
- */
- public function getImage(): ?BlockImageInterface;
-
- public function setImage(?BlockImageInterface $image): void;
-
public function getLink(): ?string;
public function setLink(?string $link): void;
diff --git a/src/EventListener/BlockImageUploadListener.php b/src/EventListener/BlockImageUploadListener.php
deleted file mode 100755
index 6de9be5f8..000000000
--- a/src/EventListener/BlockImageUploadListener.php
+++ /dev/null
@@ -1,50 +0,0 @@
-uploader = $uploader;
- }
-
- public function uploadImage(ResourceControllerEvent $event): void
- {
- $block = $event->getSubject();
-
- Assert::isInstanceOf($block, BlockInterface::class);
-
- if (BlockInterface::IMAGE_BLOCK_TYPE !== $block->getType()) {
- return;
- }
-
- /** @var BlockTranslationInterface $translation */
- foreach ($block->getTranslations() as $translation) {
- $image = $translation->getImage();
-
- if (null !== $image && true === $image->hasFile()) {
- $this->uploader->upload($image);
- }
- }
- }
-}
diff --git a/src/Exception/TemplateTypeNotFound.php b/src/Exception/TemplateTypeNotFound.php
deleted file mode 100755
index 744879bdf..000000000
--- a/src/Exception/TemplateTypeNotFound.php
+++ /dev/null
@@ -1,21 +0,0 @@
-factory = $factory;
- }
-
- public function createWithType(string $type): BlockInterface
- {
- /** @var BlockInterface $block */
- $block = $this->factory->createNew();
- $block->setType($type);
-
- return $block;
- }
-
- public function createNew(): BlockInterface
- {
- /** @var BlockInterface $block */
- $block = $this->factory->createNew();
-
- return $block;
- }
-}
diff --git a/src/Factory/BlockFactoryInterface.php b/src/Factory/BlockFactoryInterface.php
deleted file mode 100755
index ee90dcbc3..000000000
--- a/src/Factory/BlockFactoryInterface.php
+++ /dev/null
@@ -1,21 +0,0 @@
-booleanNode('remove_existing')->defaultTrue()->end()
->integerNode('number')->defaultNull()->end()
->booleanNode('last_four_products')->defaultFalse()->end()
- ->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
->booleanNode('enabled')->defaultTrue()->end()
->integerNode('products')->defaultNull()->end()
->arrayNode('sections')
diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php
index 325a5ef0b..2dffe4c11 100755
--- a/src/Fixture/Factory/BlockFixtureFactory.php
+++ b/src/Fixture/Factory/BlockFixtureFactory.php
@@ -12,7 +12,6 @@
namespace BitBag\SyliusCmsPlugin\Fixture\Factory;
-use BitBag\SyliusCmsPlugin\Entity\BlockImage;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface;
use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
@@ -21,10 +20,8 @@
use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Repository\ProductRepositoryInterface;
-use Sylius\Component\Core\Uploader\ImageUploaderInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
final class BlockFixtureFactory implements FixtureFactoryInterface
{
@@ -40,9 +37,6 @@ final class BlockFixtureFactory implements FixtureFactoryInterface
/** @var SectionRepositoryInterface */
private $sectionRepository;
- /** @var ImageUploaderInterface */
- private $imageUploader;
-
/** @var ProductRepositoryInterface */
private $productRepository;
@@ -57,7 +51,6 @@ public function __construct(
FactoryInterface $blockTranslationFactory,
BlockRepositoryInterface $blockRepository,
SectionRepositoryInterface $sectionRepository,
- ImageUploaderInterface $imageUploader,
ProductRepositoryInterface $productRepository,
ChannelContextInterface $channelContext,
LocaleContextInterface $localeContext
@@ -66,7 +59,6 @@ public function __construct(
$this->blockTranslationFactory = $blockTranslationFactory;
$this->blockRepository = $blockRepository;
$this->sectionRepository = $sectionRepository;
- $this->imageUploader = $imageUploader;
$this->productRepository = $productRepository;
$this->channelContext = $channelContext;
$this->localeContext = $localeContext;
@@ -94,8 +86,8 @@ public function load(array $data): void
private function createBlock(string $code, array $blockData): void
{
- $type = $blockData['type'];
- $block = $this->blockFactory->createWithType($type);
+ /** @var BlockInterface $block */
+ $block = $this->blockFactory->createNew();
$products = $blockData['products'];
if (null !== $products) {
@@ -116,18 +108,6 @@ private function createBlock(string $code, array $blockData): void
$blockTranslation->setName($translation['name']);
$blockTranslation->setContent($translation['content']);
$blockTranslation->setLink($translation['link']);
-
- if (BlockInterface::IMAGE_BLOCK_TYPE === $type) {
- $image = new BlockImage();
- $path = $translation['image_path'];
- $uploadedImage = new UploadedFile($path, md5($path) . '.jpg');
-
- $image->setFile($uploadedImage);
- $blockTranslation->setImage($image);
-
- $this->imageUploader->upload($image);
- }
-
$block->addTranslation($blockTranslation);
}
diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php
index 08643b2d4..9dab706fb 100644
--- a/src/Fixture/Factory/MediaFixtureFactory.php
+++ b/src/Fixture/Factory/MediaFixtureFactory.php
@@ -12,17 +12,12 @@
namespace BitBag\SyliusCmsPlugin\Fixture\Factory;
+use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface;
+use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface;
use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface;
-use BitBag\SyliusCmsPlugin\Entity\SectionInterface;
use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface;
-use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface;
-use Sylius\Component\Channel\Context\ChannelContextInterface;
-use Sylius\Component\Core\Repository\ProductRepositoryInterface;
-use Sylius\Component\Core\Uploader\ImageUploaderInterface;
-use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
final class MediaFixtureFactory implements FixtureFactoryInterface
{
@@ -35,39 +30,24 @@ final class MediaFixtureFactory implements FixtureFactoryInterface
/** @var MediaRepositoryInterface */
private $mediaRepository;
- /** @var SectionRepositoryInterface */
- private $sectionRepository;
+ /** @var ProductsAssignerInterface */
+ private $productsAssigner;
- /** @var ImageUploaderInterface */
- private $imageUploader;
-
- /** @var ProductRepositoryInterface */
- private $productRepository;
-
- /** @var ChannelContextInterface */
- private $channelContext;
-
- /** @var LocaleContextInterface */
- private $localeContext;
+ /** @var SectionsAssignerInterface */
+ private $sectionsAssigner;
public function __construct(
FactoryInterface $mediaFactory,
FactoryInterface $mediaTranslationFactory,
MediaRepositoryInterface $mediaRepository,
- SectionRepositoryInterface $sectionRepository,
- ImageUploaderInterface $imageUploader,
- ProductRepositoryInterface $productRepository,
- ChannelContextInterface $channelContext,
- LocaleContextInterface $localeContext
+ ProductsAssignerInterface $productsAssigner,
+ SectionsAssignerInterface $sectionsAssigner
) {
$this->mediaFactory = $mediaFactory;
$this->mediaTranslationFactory = $mediaTranslationFactory;
$this->mediaRepository = $mediaRepository;
- $this->sectionRepository = $sectionRepository;
- $this->imageUploader = $imageUploader;
- $this->productRepository = $productRepository;
- $this->channelContext = $channelContext;
- $this->localeContext = $localeContext;
+ $this->productsAssigner = $productsAssigner;
+ $this->sectionsAssigner = $sectionsAssigner;
}
public function load(array $data): void
@@ -94,18 +74,9 @@ private function createMedia(string $code, array $mediaData): void
{
/** @var MediaInterface $media */
$media = $this->mediaFactory->createNew();
- $products = $mediaData['products'];
-
- if (null !== $products) {
- $this->resolveProducts($media, $products);
- }
-
- $this->resolveSections($media, $mediaData['sections']);
-
$media->setType($mediaData['type']);
$media->setCode($code);
$media->setEnabled($mediaData['enabled']);
- $media->addChannel($this->channelContext->getChannel());
foreach ($mediaData['translations'] as $localeCode => $translation) {
/** @var MediaTranslationInterface $mediaTranslation */
@@ -113,46 +84,14 @@ private function createMedia(string $code, array $mediaData): void
$mediaTranslation->setLocale($localeCode);
$mediaTranslation->setName($translation['name']);
- $mediaTranslation->setContent($translation['content']);
- $mediaTranslation->setLink($translation['link']);
-
- if (MediaInterface::IMAGE_MEDIA_TYPE === $type) {
- $image = new MediaImage();
- $path = $translation['image_path'];
- $uploadedImage = new UploadedFile($path, md5($path) . '.jpg');
-
- $image->setFile($uploadedImage);
- $mediaTranslation->setImage($image);
-
- $this->imageUploader->upload($image);
- }
-
+ $mediaTranslation->setDescription($translation['description']);
+ $mediaTranslation->setAlt($translation['alt']);
$media->addTranslation($mediaTranslation);
}
- $this->mediaRepository->add($media);
- }
+ $this->sectionsAssigner->assign($media, $mediaData['sections']);
+ $this->productsAssigner->assign($media, $mediaData['products']);
- private function resolveProducts(MediaInterface $media, int $limit): void
- {
- $products = $this->productRepository->findLatestByChannel(
- $this->channelContext->getChannel(),
- $this->localeContext->getLocaleCode(),
- $limit
- );
-
- foreach ($products as $product) {
- $media->addProduct($product);
- }
- }
-
- private function resolveSections(MediaInterface $media, array $sections): void
- {
- foreach ($sections as $sectionCode) {
- /** @var SectionInterface $section */
- $section = $this->sectionRepository->findOneBy(['code' => $sectionCode]);
-
- $media->addSection($section);
- }
+ $this->mediaRepository->add($media);
}
}
diff --git a/src/Fixture/MediaFixture.php b/src/Fixture/MediaFixture.php
index 3c3c9c932..9c8c7c966 100644
--- a/src/Fixture/MediaFixture.php
+++ b/src/Fixture/MediaFixture.php
@@ -1,11 +1,11 @@
scalarNode('type')->isRequired()->cannotBeEmpty()->end()
->scalarNode('path')->isRequired()->cannotBeEmpty()->end()
->booleanNode('enabled')->defaultTrue()->end()
- ->integerNode('products')->defaultNull()->end()
->arrayNode('sections')
->prototype('scalar')->end()
->end()
+ ->arrayNode('products')
+ ->prototype('scalar')->end()
+ ->end()
->arrayNode('translations')
->prototype('array')
->children()
diff --git a/src/Form/Type/BlockType.php b/src/Form/Type/BlockType.php
index 9967595fd..d483cd124 100755
--- a/src/Form/Type/BlockType.php
+++ b/src/Form/Type/BlockType.php
@@ -13,9 +13,7 @@
namespace BitBag\SyliusCmsPlugin\Form\Type;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
-use BitBag\SyliusCmsPlugin\Form\Type\Translation\HtmlBlockTranslationType;
-use BitBag\SyliusCmsPlugin\Form\Type\Translation\ImageBlockTranslationType;
-use BitBag\SyliusCmsPlugin\Form\Type\Translation\TextBlockTranslationType;
+use BitBag\SyliusCmsPlugin\Form\Type\Translation\BlockTranslationType;
use Sylius\Bundle\ChannelBundle\Form\Type\ChannelChoiceType;
use Sylius\Bundle\ProductBundle\Form\Type\ProductAutocompleteChoiceType;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
@@ -49,55 +47,18 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'multiple' => true,
])
->add('channels', ChannelChoiceType::class, [
+ 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
+ 'required' => false,
'multiple' => true,
'expanded' => true,
- 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
])
- ;
-
- $this->resolveBlockType($block, $builder);
- }
-
- private function resolveBlockType(BlockInterface $block, FormBuilderInterface $builder): void
- {
- if (BlockInterface::TEXT_BLOCK_TYPE === $block->getType()) {
- $builder->add('translations', ResourceTranslationsType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.contents',
- 'entry_type' => TextBlockTranslationType::class,
- 'validation_groups' => ['bitbag_content'],
- 'constraints' => [
- new Valid(),
- ],
- ]);
-
- return;
- }
-
- if (BlockInterface::HTML_BLOCK_TYPE === $block->getType()) {
- $builder->add('translations', ResourceTranslationsType::class, [
+ ->add('translations', ResourceTranslationsType::class, [
'label' => 'bitbag_sylius_cms_plugin.ui.contents',
- 'entry_type' => HtmlBlockTranslationType::class,
+ 'entry_type' => BlockTranslationType::class,
'validation_groups' => ['bitbag_content'],
- 'constraints' => [
- new Valid(),
- ],
- ]);
-
- return;
- }
-
- if (BlockInterface::IMAGE_BLOCK_TYPE === $block->getType()) {
- $builder->add('translations', ResourceTranslationsType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.images',
- 'entry_type' => ImageBlockTranslationType::class,
- 'validation_groups' => null === $block->getId() ? ['bitbag_image'] : [],
- 'constraints' => [
- new Valid(),
- ],
- ]);
-
- return;
- }
+ 'constraints' => [new Valid()],
+ ])
+ ;
}
public function getBlockPrefix(): string
diff --git a/src/Form/Type/FrequentlyAskedQuestionType.php b/src/Form/Type/FrequentlyAskedQuestionType.php
index 72d2fdff1..4f818c150 100755
--- a/src/Form/Type/FrequentlyAskedQuestionType.php
+++ b/src/Form/Type/FrequentlyAskedQuestionType.php
@@ -41,9 +41,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'entry_type' => FrequentlyAskedQuestionTranslationType::class,
])
->add('channels', ChannelChoiceType::class, [
+ 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
+ 'required' => false,
'multiple' => true,
'expanded' => true,
- 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
])
;
}
diff --git a/src/Form/Type/PageType.php b/src/Form/Type/PageType.php
index 569e9a37f..b620c6455 100755
--- a/src/Form/Type/PageType.php
+++ b/src/Form/Type/PageType.php
@@ -46,9 +46,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'multiple' => true,
])
->add('channels', ChannelChoiceType::class, [
+ 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
+ 'required' => false,
'multiple' => true,
'expanded' => true,
- 'label' => 'bitbag_sylius_cms_plugin.ui.channels',
])
;
}
diff --git a/src/Form/Type/Translation/TextBlockTranslationType.php b/src/Form/Type/Translation/BlockTranslationType.php
old mode 100755
new mode 100644
similarity index 96%
rename from src/Form/Type/Translation/TextBlockTranslationType.php
rename to src/Form/Type/Translation/BlockTranslationType.php
index b768ce284..99e0ff855
--- a/src/Form/Type/Translation/TextBlockTranslationType.php
+++ b/src/Form/Type/Translation/BlockTranslationType.php
@@ -18,7 +18,7 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-final class TextBlockTranslationType extends AbstractResourceType
+final class BlockTranslationType extends AbstractResourceType
{
/** @var UrlGeneratorInterface */
private $urlGenerator;
diff --git a/src/Form/Type/Translation/HtmlBlockTranslationType.php b/src/Form/Type/Translation/HtmlBlockTranslationType.php
deleted file mode 100755
index b3286c13c..000000000
--- a/src/Form/Type/Translation/HtmlBlockTranslationType.php
+++ /dev/null
@@ -1,51 +0,0 @@
-router = $router;
- }
-
- public function buildForm(FormBuilderInterface $builder, array $options): void
- {
- $builder
- ->add('name', TextType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.name',
- 'required' => false,
- ])
- ->add('content', TextareaType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.content',
- 'required' => false,
- ])
- ;
- }
-
- public function getBlockPrefix(): string
- {
- return 'bitbag_sylius_cms_plugin_text_translation';
- }
-}
diff --git a/src/Form/Type/Translation/ImageBlockTranslationType.php b/src/Form/Type/Translation/ImageBlockTranslationType.php
deleted file mode 100755
index 7db590df9..000000000
--- a/src/Form/Type/Translation/ImageBlockTranslationType.php
+++ /dev/null
@@ -1,62 +0,0 @@
-urlGenerator = $urlGenerator;
- }
-
- public function buildForm(FormBuilderInterface $builder, array $options): void
- {
- $builder
- ->add('name', TextType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.name',
- 'required' => false,
- ])
- ->add('link', TextType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.link',
- 'required' => false,
- ])
- ->add('image', BlockImageType::class, [
- 'label' => false,
- 'required' => true,
- ])
- ->add('content', CKEditorType::class, [
- 'label' => 'bitbag_sylius_cms_plugin.ui.content',
- 'config' => [
- 'filebrowserUploadUrl' => $this->urlGenerator->generate('bitbag_sylius_cms_plugin_admin_upload_editor_image'),
- ],
- ])
- ;
- }
-
- public function getBlockPrefix(): string
- {
- return 'bitbag_sylius_cms_plugin_image_translation';
- }
-}
diff --git a/src/Importer/BlockImporter.php b/src/Importer/BlockImporter.php
index 90d180f93..4b1c9e69c 100644
--- a/src/Importer/BlockImporter.php
+++ b/src/Importer/BlockImporter.php
@@ -12,16 +12,12 @@
namespace BitBag\SyliusCmsPlugin\Importer;
-use BitBag\SyliusCmsPlugin\Downloader\ImageDownloaderInterface;
-use BitBag\SyliusCmsPlugin\Entity\BlockImage;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
-use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface;
use Doctrine\ORM\EntityManagerInterface;
-use Sylius\Component\Core\Uploader\ImageUploaderInterface;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Webmozart\Assert\Assert;
@@ -33,12 +29,6 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInter
/** @var LocaleContextInterface */
private $localeContext;
- /** @var ImageDownloaderInterface */
- private $imageDownloader;
-
- /** @var ImageUploaderInterface */
- private $imageUploader;
-
/** @var ImporterSectionsResolverInterface */
private $importerSectionsResolver;
@@ -54,8 +44,6 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInter
public function __construct(
ResourceResolverInterface $blockResourceResolver,
LocaleContextInterface $localeContext,
- ImageDownloaderInterface $imageDownloader,
- ImageUploaderInterface $imageUploader,
ImporterSectionsResolverInterface $importerSectionsResolver,
ImporterChannelsResolverInterface $importerChannelsResolver,
ImporterProductsResolverInterface $importerProductsResolver,
@@ -63,8 +51,6 @@ public function __construct(
) {
$this->blockResourceResolver = $blockResourceResolver;
$this->localeContext = $localeContext;
- $this->imageDownloader = $imageDownloader;
- $this->imageUploader = $imageUploader;
$this->importerSectionsResolver = $importerSectionsResolver;
$this->importerChannelsResolver = $importerChannelsResolver;
$this->importerProductsResolver = $importerProductsResolver;
@@ -76,12 +62,10 @@ public function import(array $row): void
/** @var string $code */
$code = $this->getColumnValue(self::CODE_COLUMN, $row);
Assert::notNull($code);
- $type = $this->getColumnValue(self::TYPE_COLUMN, $row);
/** @var BlockInterface $block */
$block = $this->blockResourceResolver->getResource($code);
$block->setCode($code);
- $block->setType($type);
$block->setFallbackLocale($this->localeContext->getLocaleCode());
foreach ($this->getAvailableLocales($this->getTranslatableColumns(), array_keys($row)) as $locale) {
@@ -89,12 +73,6 @@ public function import(array $row): void
$block->setName($this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row));
$block->setLink($this->getTranslatableColumnValue(self::LINK_COLUMN, $locale, $row));
$block->setContent($this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row));
-
- $url = $this->getTranslatableColumnValue(self::IMAGE_COLUMN, $locale, $row);
-
- if (null !== $url && BlockInterface::IMAGE_BLOCK_TYPE === $type) {
- $this->resolveImage($block, $url ?? '', $locale);
- }
}
$this->importerSectionsResolver->resolve($block, $this->getColumnValue(self::SECTIONS_COLUMN, $row));
@@ -110,31 +88,11 @@ public function getResourceCode(): string
return 'block';
}
- private function resolveImage(BlockInterface $block, string $url, string $locale): void
- {
- /** @var BlockTranslationInterface $blockTranslation */
- $blockTranslation = $block->getTranslation($locale);
- $downloadedImage = $this->imageDownloader->download($url);
-
- if (null !== $blockImage = $blockTranslation->getImage()) {
- $this->imageUploader->remove($blockTranslation->getImage()->getPath());
- } else {
- $blockImage = new BlockImage();
- }
-
- $blockImage->setFile($downloadedImage);
- $blockImage->setOwner($blockTranslation);
-
- $this->imageUploader->upload($blockImage);
- $this->entityManager->persist($blockImage);
- }
-
private function getTranslatableColumns(): array
{
return [
self::NAME_COLUMN,
self::CONTENT_COLUMN,
- self::IMAGE_COLUMN,
self::LINK_COLUMN,
];
}
diff --git a/src/Importer/BlockImporterInterface.php b/src/Importer/BlockImporterInterface.php
index 0d0ae1e9d..8a20b6be7 100644
--- a/src/Importer/BlockImporterInterface.php
+++ b/src/Importer/BlockImporterInterface.php
@@ -15,12 +15,10 @@
interface BlockImporterInterface extends ImporterInterface
{
const CODE_COLUMN = 'code';
- const TYPE_COLUMN = 'type';
const SECTIONS_COLUMN = 'sections';
const CHANNELS_COLUMN = 'channels';
const PRODUCTS_COLUMN = 'products';
const NAME_COLUMN = 'name__locale__';
const CONTENT_COLUMN = 'content__locale__';
const LINK_COLUMN = 'link__locale__';
- const IMAGE_COLUMN = 'image__locale__';
}
diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php
index 6605ecc5e..88cecffc6 100644
--- a/src/Importer/PageImporter.php
+++ b/src/Importer/PageImporter.php
@@ -64,8 +64,7 @@ public function __construct(
ImporterChannelsResolverInterface $importerChannelsResolver,
ImporterProductsResolverInterface $importerProductsResolver,
EntityManagerInterface $entityManager
- )
- {
+ ) {
$this->pageResourceResolver = $pageResourceResolver;
$this->sectionResolver = $sectionResolver;
$this->localeContext = $localeContext;
diff --git a/src/Resolver/BlockResourceResolver.php b/src/Resolver/BlockResourceResolver.php
index 36d32a65c..3966e667f 100755
--- a/src/Resolver/BlockResourceResolver.php
+++ b/src/Resolver/BlockResourceResolver.php
@@ -41,7 +41,6 @@ public function __construct(
public function findOrLog(string $code): ?BlockInterface
{
$channel = $this->channelContext->getChannel();
-
$block = $this->blockRepository->findEnabledByCode($code, $channel->getCode());
if (false === $block instanceof BlockInterface) {
diff --git a/src/Resolver/BlockTemplateResolver.php b/src/Resolver/BlockTemplateResolver.php
deleted file mode 100755
index 6d51bdbf0..000000000
--- a/src/Resolver/BlockTemplateResolver.php
+++ /dev/null
@@ -1,36 +0,0 @@
-getType()) {
- return BlockTemplateResolverInterface::TEXT_BLOCK_TEMPLATE;
- }
-
- if (BlockInterface::HTML_BLOCK_TYPE === $block->getType()) {
- return BlockTemplateResolverInterface::HTML_BLOCK_TEMPLATE;
- }
-
- if (BlockInterface::IMAGE_BLOCK_TYPE === $block->getType()) {
- return BlockTemplateResolverInterface::IMAGE_BLOCK_TEMPLATE;
- }
-
- throw new TemplateTypeNotFound($block->getType());
- }
-}
diff --git a/src/Resolver/BlockTemplateResolverInterface.php b/src/Resolver/BlockTemplateResolverInterface.php
deleted file mode 100755
index 7a39f0cc9..000000000
--- a/src/Resolver/BlockTemplateResolverInterface.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
diff --git a/src/Resources/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig
index 8d551daa0..57af30bc7 100755
--- a/src/Resources/views/Form/theme.html.twig
+++ b/src/Resources/views/Form/theme.html.twig
@@ -6,4 +6,4 @@
{% block sylius_product_autocomplete_choice_row %}
{{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/src/Resources/views/Grid/Action/createBlock.html.twig b/src/Resources/views/Grid/Action/createBlock.html.twig
deleted file mode 100755
index 7f21f5e8d..000000000
--- a/src/Resources/views/Grid/Action/createBlock.html.twig
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- {{ 'sylius.ui.create'|trans }}
-
-
diff --git a/src/Resources/views/Grid/Field/content.html.twig b/src/Resources/views/Grid/Field/content.html.twig
index 961f0b9b7..f5032734e 100755
--- a/src/Resources/views/Grid/Field/content.html.twig
+++ b/src/Resources/views/Grid/Field/content.html.twig
@@ -1,7 +1 @@
-{% set type = data.type %}
-
-{% if 'text' == type or 'html' == type %}
- {{ data.content|length > 25 ? data.content|slice(0, 25) ~ '...' : data.content }}
-{% elseif 'image' == type %}
-
-{% endif %}
+{{ data.content|length > 25 ? data.content|slice(0, 25) ~ '...' : data.content }}
diff --git a/src/Resources/views/Shop/Block/Show/_image.html.twig b/src/Resources/views/Shop/Block/Show/_image.html.twig
deleted file mode 100755
index 1d35170e3..000000000
--- a/src/Resources/views/Shop/Block/Show/_image.html.twig
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/Resources/views/Shop/Block/Show/htmlBlock.html.twig b/src/Resources/views/Shop/Block/Show/htmlBlock.html.twig
deleted file mode 100755
index c07c63ad9..000000000
--- a/src/Resources/views/Shop/Block/Show/htmlBlock.html.twig
+++ /dev/null
@@ -1,7 +0,0 @@
-
- {% if null != block.name %}
-
{{ block.name }}
- {% endif %}
-
- {{ bitbag_cms_render_content(block) }}
-
diff --git a/src/Resources/views/Shop/Block/Show/imageBlock.html.twig b/src/Resources/views/Shop/Block/Show/imageBlock.html.twig
deleted file mode 100755
index 2c8107643..000000000
--- a/src/Resources/views/Shop/Block/Show/imageBlock.html.twig
+++ /dev/null
@@ -1,30 +0,0 @@
-{% set path = '/media/image/'~block.image.path %}
-
-
diff --git a/src/Resources/views/Shop/Block/Show/textBlock.html.twig b/src/Resources/views/Shop/Block/show.html.twig
old mode 100755
new mode 100644
similarity index 100%
rename from src/Resources/views/Shop/Block/Show/textBlock.html.twig
rename to src/Resources/views/Shop/Block/show.html.twig
diff --git a/src/Twig/Extension/RenderBlockExtension.php b/src/Twig/Extension/RenderBlockExtension.php
index f0cade41e..822ea5ef4 100644
--- a/src/Twig/Extension/RenderBlockExtension.php
+++ b/src/Twig/Extension/RenderBlockExtension.php
@@ -14,7 +14,6 @@
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use BitBag\SyliusCmsPlugin\Resolver\BlockResourceResolverInterface;
-use BitBag\SyliusCmsPlugin\Resolver\BlockTemplateResolverInterface;
use Symfony\Component\Templating\EngineInterface;
final class RenderBlockExtension extends \Twig_Extension
@@ -22,9 +21,6 @@ final class RenderBlockExtension extends \Twig_Extension
/** @var BlockRepositoryInterface */
private $blockRepository;
- /** @var BlockTemplateResolverInterface */
- private $blockTemplateResolver;
-
/** @var BlockResourceResolverInterface */
private $blockResourceResolver;
@@ -33,12 +29,10 @@ final class RenderBlockExtension extends \Twig_Extension
public function __construct(
BlockRepositoryInterface $blockRepository,
- BlockTemplateResolverInterface $blockTemplateResolver,
BlockResourceResolverInterface $blockResourceResolver,
EngineInterface $templatingEngine
) {
$this->blockRepository = $blockRepository;
- $this->blockTemplateResolver = $blockTemplateResolver;
$this->blockResourceResolver = $blockResourceResolver;
$this->templatingEngine = $templatingEngine;
}
@@ -55,7 +49,7 @@ public function renderBlock(string $code, ?string $template = null): string
$block = $this->blockResourceResolver->findOrLog($code);
if (null !== $block) {
- $template = $template ?? $this->blockTemplateResolver->resolveTemplate($block);
+ $template = $template ?? '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig';
return $this->templatingEngine->render($template, ['block' => $block]);
}
diff --git a/tests/Application/app/Resources/fixtures/ford_mustang_gt.jpg b/tests/Application/app/Resources/fixtures/ford_mustang_gt.jpg
new file mode 100644
index 000000000..3d63d14a0
Binary files /dev/null and b/tests/Application/app/Resources/fixtures/ford_mustang_gt.jpg differ
diff --git a/tests/Application/app/config/fixtures.yml b/tests/Application/app/config/fixtures.yml
index e015399e8..2e8b4702b 100755
--- a/tests/Application/app/config/fixtures.yml
+++ b/tests/Application/app/config/fixtures.yml
@@ -197,3 +197,13 @@ sylius_fixtures:
Estne, quaeso, inquam, sitienti in bibendo voluptas?
answer: |
Nam his libris eum malo quam reliquo ornatu villae delectari. Quid est, quod ab ea absolvi et perfici debeat? Ex quo, id quod omnes expetunt, beate vivendi ratio inveniri et comparari potest. Stoici scilicet.
+ media:
+ options:
+ custom:
+ test_image:
+ translations:
+ en_US:
+ question: |
+ Estne, quaeso, inquam, sitienti in bibendo voluptas?
+ answer: |
+ Nam his libris eum malo quam reliquo ornatu villae delectari. Quid est, quod ab ea absolvi et perfici debeat? Ex quo, id quod omnes expetunt, beate vivendi ratio inveniri et comparari potest. Stoici scilicet.
diff --git a/tests/Behat/Behaviour/ChecksCodeImmutabilityInterface.php b/tests/Behat/Behaviour/ChecksCodeImmutabilityInterface.php
index c7278e5e4..fa3d09705 100755
--- a/tests/Behat/Behaviour/ChecksCodeImmutabilityInterface.php
+++ b/tests/Behat/Behaviour/ChecksCodeImmutabilityInterface.php
@@ -14,8 +14,5 @@
interface ChecksCodeImmutabilityInterface
{
- /**
- * @return bool
- */
public function isCodeDisabled(): bool;
}
diff --git a/tests/Behat/Behaviour/ChecksCodeImmutabilityTrait.php b/tests/Behat/Behaviour/ChecksCodeImmutabilityTrait.php
index 7ca5ed008..a2d33daf9 100755
--- a/tests/Behat/Behaviour/ChecksCodeImmutabilityTrait.php
+++ b/tests/Behat/Behaviour/ChecksCodeImmutabilityTrait.php
@@ -18,9 +18,6 @@ trait ChecksCodeImmutabilityTrait
{
use DocumentAccessor;
- /**
- * @return bool
- */
public function isCodeDisabled(): bool
{
return 'disabled' === $this->getDocument()->findField('Code')->getAttribute('disabled');
diff --git a/tests/Behat/Behaviour/ContainsEmptyListInterface.php b/tests/Behat/Behaviour/ContainsEmptyListInterface.php
index d4b8f3b07..46ee5097f 100755
--- a/tests/Behat/Behaviour/ContainsEmptyListInterface.php
+++ b/tests/Behat/Behaviour/ContainsEmptyListInterface.php
@@ -14,8 +14,5 @@
interface ContainsEmptyListInterface
{
- /**
- * @return bool
- */
public function isEmpty(): bool;
}
diff --git a/tests/Behat/Behaviour/ContainsEmptyListTrait.php b/tests/Behat/Behaviour/ContainsEmptyListTrait.php
index 8e9f8154f..b31e02126 100755
--- a/tests/Behat/Behaviour/ContainsEmptyListTrait.php
+++ b/tests/Behat/Behaviour/ContainsEmptyListTrait.php
@@ -18,9 +18,6 @@ trait ContainsEmptyListTrait
{
use DocumentAccessor;
- /**
- * {@inheritdoc}
- */
public function isEmpty(): bool
{
return false !== strpos($this->getDocument()->find('css', '.message')->getText(), 'There are no results to display');
diff --git a/tests/Behat/Behaviour/ContainsErrorInterface.php b/tests/Behat/Behaviour/ContainsErrorInterface.php
index 628a4cbc0..1352b7fe5 100755
--- a/tests/Behat/Behaviour/ContainsErrorInterface.php
+++ b/tests/Behat/Behaviour/ContainsErrorInterface.php
@@ -14,11 +14,5 @@
interface ContainsErrorInterface
{
- /**
- * @param string $message
- * @param bool $strict
- *
- * @return bool
- */
public function containsErrorWithMessage(string $message, bool $strict = true): bool;
}
diff --git a/tests/Behat/Behaviour/ContainsErrorTrait.php b/tests/Behat/Behaviour/ContainsErrorTrait.php
index e9c397d95..db0424862 100755
--- a/tests/Behat/Behaviour/ContainsErrorTrait.php
+++ b/tests/Behat/Behaviour/ContainsErrorTrait.php
@@ -19,12 +19,6 @@ trait ContainsErrorTrait
{
use DocumentAccessor;
- /**
- * @param string $message
- * @param bool $strict
- *
- * @return bool
- */
public function containsErrorWithMessage(string $message, bool $strict = true): bool
{
$validationMessageElements = $this->getDocument()->findAll('css', '.sylius-validation-error');
diff --git a/tests/Behat/Context/Setup/BlockContext.php b/tests/Behat/Context/Setup/BlockContext.php
index b15e0b429..6e063e0b2 100755
--- a/tests/Behat/Context/Setup/BlockContext.php
+++ b/tests/Behat/Context/Setup/BlockContext.php
@@ -13,83 +13,47 @@
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Setup;
use Behat\Behat\Context\Context;
-use BitBag\SyliusCmsPlugin\Entity\BlockImage;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
-use BitBag\SyliusCmsPlugin\Factory\BlockFactoryInterface;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\ChannelInterface;
-use Sylius\Component\Core\Model\ImageInterface;
-use Sylius\Component\Core\Uploader\ImageUploaderInterface;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Sylius\Component\Resource\Factory\FactoryInterface;
use Tests\BitBag\SyliusCmsPlugin\Behat\Service\RandomStringGeneratorInterface;
final class BlockContext implements Context
{
- const IMAGE_MOCK = 'aston_martin_db_11.jpg';
-
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var BlockFactoryInterface
- */
+ /** @var FactoryInterface */
private $blockFactory;
- /**
- * @var BlockRepositoryInterface
- */
+ /** @var BlockRepositoryInterface */
private $blockRepository;
- /**
- * @var ImageUploaderInterface
- */
- private $imageUploader;
-
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param BlockFactoryInterface $blockFactory
- * @param BlockRepositoryInterface $blockRepository
- * @param ImageUploaderInterface $imageUploader
- */
public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
- BlockFactoryInterface $blockFactory,
- BlockRepositoryInterface $blockRepository,
- ImageUploaderInterface $imageUploader
- ) {
+ FactoryInterface $blockFactory,
+ BlockRepositoryInterface $blockRepository
+ )
+ {
$this->sharedStorage = $sharedStorage;
$this->randomStringGenerator = $randomStringGenerator;
$this->blockFactory = $blockFactory;
$this->blockRepository = $blockRepository;
- $this->imageUploader = $imageUploader;
}
/**
+ * @Given there is a dynamic content block
* @Given there is a block in the store
*/
- public function thereIsABlockInTheStore(): void
+ public function thereIsADynamicContentBlock(): void
{
- $block = $this->createBlock(BlockInterface::TEXT_BLOCK_TYPE);
-
- $this->saveBlock($block);
- }
-
- /**
- * @Given there is a dynamic content block with :type type
- */
- public function thereIsADynamicContentBlockWithType(string $type): void
- {
- $block = $this->createBlock($type);
+ $block = $this->createBlock();
$this->saveBlock($block);
}
@@ -99,58 +63,29 @@ public function thereIsADynamicContentBlockWithType(string $type): void
*/
public function thereIsABlockWithCode(string $code): void
{
- $block = $this->createBlock(BlockInterface::TEXT_BLOCK_TYPE, $code);
+ $block = $this->createBlock($code);
$this->saveBlock($block);
}
/**
- * @Given there is a text block with :code code and :content content
+ * @Given there is a block with :code code and :content content
*/
- public function thereIsATextBlockWithCodeAndContent(string $code, string $content): void
+ public function thereIsABlockWithCodeAndContent(string $code, string $content): void
{
- $block = $this->createBlock(BlockInterface::TEXT_BLOCK_TYPE, $code, $content);
+ $block = $this->createBlock($code, $content);
$this->saveBlock($block);
}
- /**
- * @Given there is a html block with :code code and :content content
- */
- public function thereIsAHtmlBlockWithCodeAndContent(string $code, string $content): void
- {
- $block = $this->createBlock(BlockInterface::HTML_BLOCK_TYPE, $code, $content);
-
- $this->saveBlock($block);
- }
-
- /**
- * @Given there is an existing block with :code code and :image image
- */
- public function thereIsAnExistingBlockWithCodeAndImage(string $code, string $image): void
- {
- $block = $this->createBlock(BlockInterface::IMAGE_BLOCK_TYPE, $code, null, $image);
-
- $this->saveBlock($block);
- }
-
- /**
- * @param string $type
- * @param string|null $code
- * @param string|null $content
- * @param string|null $image
- * @param ChannelInterface $channel
- *
- * @return BlockInterface
- */
private function createBlock(
- string $type,
?string $code = null,
?string $content = null,
- string $image = null,
ChannelInterface $channel = null
- ): BlockInterface {
- $block = $this->blockFactory->createWithType($type);
+ ): BlockInterface
+ {
+ /** @var BlockInterface $block */
+ $block = $this->blockFactory->createNew();
$block->setCurrentLocale('en_US');
@@ -162,46 +97,17 @@ private function createBlock(
$code = $this->randomStringGenerator->generate();
}
- if (BlockInterface::IMAGE_BLOCK_TYPE === $type && null !== $image) {
- $image = $this->uploadImage($image);
-
- $block->setImage($image);
- }
-
- if (true === in_array($type, [BlockInterface::HTML_BLOCK_TYPE, BlockInterface::TEXT_BLOCK_TYPE])) {
- if (null === $content) {
- $content = $this->randomStringGenerator->generate();
- }
-
- $block->setContent($content);
+ if (null === $content) {
+ $content = $this->randomStringGenerator->generate();
}
$block->setCode($code);
+ $block->setContent($content);
$block->addChannel($channel);
return $block;
}
- /**
- * @param string $name
- *
- * @return ImageInterface
- */
- private function uploadImage(string $name): ImageInterface
- {
- $image = new BlockImage();
- $uploadedImage = new UploadedFile(__DIR__ . '/../../Resources/images/' . $name, $name);
-
- $image->setFile($uploadedImage);
-
- $this->imageUploader->upload($image);
-
- return $image;
- }
-
- /**
- * @param BlockInterface $block
- */
private function saveBlock(BlockInterface $block): void
{
$this->blockRepository->add($block);
diff --git a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php
index 0042d43a4..b5dc879af 100755
--- a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php
+++ b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php
@@ -22,27 +22,15 @@
final class FrequentlyAskedQuestionContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var FactoryInterface
- */
+ /** @var FactoryInterface */
private $frequentlyAskedQuestionFactory;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param FactoryInterface $frequentlyAskedQuestionFactory
- * @param FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository
- */
public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
@@ -55,9 +43,7 @@ public function __construct(
$this->frequentlyAskedQuestionRepository = $frequentlyAskedQuestionRepository;
}
- /**
- * @var FrequentlyAskedQuestionRepositoryInterface
- */
+ /** @var FrequentlyAskedQuestionRepositoryInterface */
private $frequentlyAskedQuestionRepository;
/**
@@ -147,9 +133,6 @@ private function createFrequentlyAskedQuestion(
return $frequentlyAskedQuestion;
}
- /**
- * @param FrequentlyAskedQuestionInterface $frequentlyAskedQuestion
- */
private function saveFrequentlyAskedQuestion(FrequentlyAskedQuestionInterface $frequentlyAskedQuestion): void
{
$this->frequentlyAskedQuestionRepository->add($frequentlyAskedQuestion);
diff --git a/tests/Behat/Context/Setup/MediaContext.php b/tests/Behat/Context/Setup/MediaContext.php
index 5366d3239..e7d751f89 100755
--- a/tests/Behat/Context/Setup/MediaContext.php
+++ b/tests/Behat/Context/Setup/MediaContext.php
@@ -26,44 +26,28 @@
final class MediaContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var FactoryInterface
- */
+ /** @var FactoryInterface */
private $mediaFactory;
- /**
- * @var MediaRepositoryInterface
- */
+ /** @var MediaRepositoryInterface */
private $mediaRepository;
- /**
- * @var EntityManagerInterface
- */
+ /** @var EntityManagerInterface */
private $entityManager;
- /**
- * @var ProductRepositoryInterface
- */
+ /** @var ProductRepositoryInterface */
private $productRepository;
- /**
- * @var SectionRepositoryInterface
- */
+ /** @var SectionRepositoryInterface */
private $sectionRepository;
- /**
- * @var MediaProviderResolverInterface
- */
+ /** @var MediaProviderResolverInterface */
private $mediaProviderResolver;
public function __construct(
diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php
index c4c7a3231..20fba1f08 100755
--- a/tests/Behat/Context/Setup/PageContext.php
+++ b/tests/Behat/Context/Setup/PageContext.php
@@ -30,55 +30,30 @@
final class PageContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var FactoryInterface
- */
+ /** @var FactoryInterface */
private $pageFactory;
- /**
- * @var PageRepositoryInterface
- */
+ /** @var PageRepositoryInterface */
private $pageRepository;
- /**
- * @var EntityManagerInterface
- */
+ /** @var EntityManagerInterface */
private $entityManager;
- /**
- * @var ProductRepositoryInterface
- */
+ /** @var ProductRepositoryInterface */
private $productRepository;
- /**
- * @var SectionRepositoryInterface
- */
+ /** @var SectionRepositoryInterface */
private $sectionRepository;
- /**
- * @var ImageUploaderInterface
- */
+ /** @var ImageUploaderInterface */
private $imageUploader;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param FactoryInterface $pageFactory
- * @param PageRepositoryInterface $pageRepository
- * @param EntityManagerInterface $entityManager
- * @param ProductRepositoryInterface $productRepository
- * @param SectionRepositoryInterface $sectionRepository
- */
public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
@@ -237,14 +212,6 @@ public function thesePagesHaveThisSectionAssociatedWithIt(): void
$this->entityManager->flush();
}
- /**
- * @param string|null $code
- * @param string|null $name
- * @param string|null $content
- * @param ChannelInterface|null $channel
- *
- * @return PageContentInterface
- */
private function createPage(?string $code = null, ?string $name = null, ?string $content = null, ChannelInterface $channel = null): PageContentInterface
{
/** @var PageContentInterface $page */
@@ -276,11 +243,6 @@ private function createPage(?string $code = null, ?string $name = null, ?string
return $page;
}
- /**
- * @param string $name
- *
- * @return ImageInterface
- */
private function uploadImage(string $name): ImageInterface
{
$image = new PageImage();
@@ -293,9 +255,6 @@ private function uploadImage(string $name): ImageInterface
return $image;
}
- /**
- * @param PageContentInterface $page
- */
private function savePage(PageContentInterface $page): void
{
$this->pageRepository->add($page);
diff --git a/tests/Behat/Context/Setup/SectionContext.php b/tests/Behat/Context/Setup/SectionContext.php
index 7c1efc66d..2f339ae17 100755
--- a/tests/Behat/Context/Setup/SectionContext.php
+++ b/tests/Behat/Context/Setup/SectionContext.php
@@ -23,27 +23,15 @@
final class SectionContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var FactoryInterface
- */
+ /** @var FactoryInterface */
private $sectionFactory;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param FactoryInterface $sectionFactory
- * @param SectionRepositoryInterface $sectionRepository
- */
public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
@@ -56,9 +44,7 @@ public function __construct(
$this->sectionRepository = $sectionRepository;
}
- /**
- * @var SectionRepositoryInterface
- */
+ /** @var SectionRepositoryInterface */
private $sectionRepository;
/**
@@ -103,13 +89,6 @@ public function thereIsASectionInTheStore(string $sectionName): void
$this->saveSection($section);
}
- /**
- * @param string|null $code
- * @param string|null $name
- * @param ChannelInterface|null $channel
- *
- * @return SectionInterface
- */
private function createSection(?string $code = null, string $name = null, ChannelInterface $channel = null): SectionInterface
{
/** @var SectionInterface $section */
@@ -135,9 +114,6 @@ private function createSection(?string $code = null, string $name = null, Channe
return $section;
}
- /**
- * @param SectionInterface $section
- */
private function saveSection(SectionInterface $section): void
{
$this->sectionRepository->add($section);
diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php
index 8d33dd515..430c63905 100755
--- a/tests/Behat/Context/Ui/Admin/BlockContext.php
+++ b/tests/Behat/Context/Ui/Admin/BlockContext.php
@@ -13,8 +13,6 @@
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Ui\Admin;
use Behat\Behat\Context\Context;
-use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
-use BitBag\SyliusCmsPlugin\Exception\TemplateTypeNotFound;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\SymfonyPageInterface;
@@ -29,56 +27,30 @@
final class BlockContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var CurrentPageResolverInterface
- */
+ /** @var CurrentPageResolverInterface */
private $currentPageResolver;
- /**
- * @var NotificationCheckerInterface
- */
+ /** @var NotificationCheckerInterface */
private $notificationChecker;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var CreatePageInterface
- */
+ /** @var CreatePageInterface */
private $createPage;
- /**
- * @var UpdatePageInterface
- */
+ /** @var UpdatePageInterface */
private $updatePage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @var BlockRepositoryInterface
- */
+ /** @var BlockRepositoryInterface */
private $blockRepository;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param CurrentPageResolverInterface $currentPageResolver
- * @param NotificationCheckerInterface $notificationChecker
- * @param IndexPageInterface $indexPage
- * @param CreatePageInterface $createPage
- * @param UpdatePageInterface $updatePage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param BlockRepositoryInterface $blockRepository
- */
public function __construct(
SharedStorageInterface $sharedStorage,
CurrentPageResolverInterface $currentPageResolver,
@@ -108,29 +80,11 @@ public function iGoToTheBlocksPage()
}
/**
- * @When I go to the create :blockType block page
+ * @When I go to the create block page
*/
- public function iGoToTheCreateImageBlockPage(string $blockType): void
+ public function iGoToTheCreateImageBlockPage(): void
{
- if (BlockInterface::TEXT_BLOCK_TYPE === $blockType) {
- $this->createPage->open(['type' => BlockInterface::TEXT_BLOCK_TYPE]);
-
- return;
- }
-
- if (BlockInterface::HTML_BLOCK_TYPE === $blockType) {
- $this->createPage->open(['type' => BlockInterface::HTML_BLOCK_TYPE]);
-
- return;
- }
-
- if (BlockInterface::IMAGE_BLOCK_TYPE === $blockType) {
- $this->createPage->open(['type' => BlockInterface::IMAGE_BLOCK_TYPE]);
-
- return;
- }
-
- throw new TemplateTypeNotFound($blockType);
+ $this->createPage->open();
}
/**
@@ -342,20 +296,6 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void
}
}
- /**
- * @Then I should be able to select between :firstBlockType, :secondBlockType and :thirdBlockType block types under Create button
- */
- public function iShouldBeAbleToSelectBetweenAndBlockTypesUnderCreateButton(string ...$blockTypes): void
- {
- $blockTypesOnPage = $this->indexPage->getBlockTypes();
-
- Assert::eq(count($blockTypesOnPage), count($blockTypes));
-
- foreach ($blockTypes as $blockType) {
- Assert::oneOf($blockType, $blockTypesOnPage);
- }
- }
-
/**
* @Then the code field should be disabled
*/
diff --git a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php
index a34e0ab73..c350bfbcb 100755
--- a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php
+++ b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php
@@ -26,50 +26,27 @@
final class FrequentlyAskedQuestionContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var CurrentPageResolverInterface
- */
+ /** @var CurrentPageResolverInterface */
private $currentPageResolver;
- /**
- * @var NotificationCheckerInterface
- */
+ /** @var NotificationCheckerInterface */
private $notificationChecker;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var CreatePageInterface
- */
+ /** @var CreatePageInterface */
private $createPage;
- /**
- * @var UpdatePageInterface
- */
+ /** @var UpdatePageInterface */
private $updatePage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param CurrentPageResolverInterface $currentPageResolver
- * @param NotificationCheckerInterface $notificationChecker
- * @param IndexPageInterface $indexPage
- * @param CreatePageInterface $createPage
- * @param UpdatePageInterface $updatePage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- */
public function __construct(
SharedStorageInterface $sharedStorage,
CurrentPageResolverInterface $currentPageResolver,
diff --git a/tests/Behat/Context/Ui/Admin/MediaContext.php b/tests/Behat/Context/Ui/Admin/MediaContext.php
index 0c8662ae2..b97e536bd 100755
--- a/tests/Behat/Context/Ui/Admin/MediaContext.php
+++ b/tests/Behat/Context/Ui/Admin/MediaContext.php
@@ -27,44 +27,28 @@
final class MediaContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var CurrentPageResolverInterface
- */
+ /** @var CurrentPageResolverInterface */
private $currentPageResolver;
- /**
- * @var NotificationCheckerInterface
- */
+ /** @var NotificationCheckerInterface */
private $notificationChecker;
- /**
- * @var MediaRepositoryInterface
- */
+ /** @var MediaRepositoryInterface */
private $mediaRepository;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var CreatePageInterface
- */
+ /** @var CreatePageInterface */
private $createPage;
- /**
- * @var UpdatePageInterface
- */
+ /** @var UpdatePageInterface */
private $updatePage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
public function __construct(
diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php
index ed4e6ebde..6fef8be95 100755
--- a/tests/Behat/Context/Ui/Admin/PageContext.php
+++ b/tests/Behat/Context/Ui/Admin/PageContext.php
@@ -27,56 +27,30 @@
final class PageContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var CurrentPageResolverInterface
- */
+ /** @var CurrentPageResolverInterface */
private $currentPageResolver;
- /**
- * @var NotificationCheckerInterface
- */
+ /** @var NotificationCheckerInterface */
private $notificationChecker;
- /**
- * @var PageRepositoryInterface
- */
+ /** @var PageRepositoryInterface */
private $pageRepository;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var CreatePageInterface
- */
+ /** @var CreatePageInterface */
private $createPage;
- /**
- * @var UpdatePageInterface
- */
+ /** @var UpdatePageInterface */
private $updatePage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param CurrentPageResolverInterface $currentPageResolver
- * @param NotificationCheckerInterface $notificationChecker
- * @param IndexPageInterface $indexPage
- * @param CreatePageInterface $createPage
- * @param UpdatePageInterface $updatePage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- * @param PageRepositoryInterface $pageRepository
- */
public function __construct(
SharedStorageInterface $sharedStorage,
CurrentPageResolverInterface $currentPageResolver,
diff --git a/tests/Behat/Context/Ui/Admin/SectionContext.php b/tests/Behat/Context/Ui/Admin/SectionContext.php
index a2268b7dc..999a3dcae 100755
--- a/tests/Behat/Context/Ui/Admin/SectionContext.php
+++ b/tests/Behat/Context/Ui/Admin/SectionContext.php
@@ -26,50 +26,27 @@
final class SectionContext implements Context
{
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @var CurrentPageResolverInterface
- */
+ /** @var CurrentPageResolverInterface */
private $currentPageResolver;
- /**
- * @var NotificationCheckerInterface
- */
+ /** @var NotificationCheckerInterface */
private $notificationChecker;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var CreatePageInterface
- */
+ /** @var CreatePageInterface */
private $createPage;
- /**
- * @var UpdatePageInterface
- */
+ /** @var UpdatePageInterface */
private $updatePage;
- /**
- * @var RandomStringGeneratorInterface
- */
+ /** @var RandomStringGeneratorInterface */
private $randomStringGenerator;
- /**
- * @param SharedStorageInterface $sharedStorage
- * @param CurrentPageResolverInterface $currentPageResolver
- * @param NotificationCheckerInterface $notificationChecker
- * @param IndexPageInterface $indexPage
- * @param CreatePageInterface $createPage
- * @param UpdatePageInterface $updatePage
- * @param RandomStringGeneratorInterface $randomStringGenerator
- */
public function __construct(
SharedStorageInterface $sharedStorage,
CurrentPageResolverInterface $currentPageResolver,
diff --git a/tests/Behat/Context/Ui/Shop/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Ui/Shop/FrequentlyAskedQuestionContext.php
index b62bc8b31..10200b61d 100755
--- a/tests/Behat/Context/Ui/Shop/FrequentlyAskedQuestionContext.php
+++ b/tests/Behat/Context/Ui/Shop/FrequentlyAskedQuestionContext.php
@@ -18,14 +18,9 @@
final class FrequentlyAskedQuestionContext implements Context
{
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @param IndexPageInterface $indexPage
- */
public function __construct(IndexPageInterface $indexPage)
{
$this->indexPage = $indexPage;
diff --git a/tests/Behat/Context/Ui/Shop/HomepageBlocksContext.php b/tests/Behat/Context/Ui/Shop/HomepageBlocksContext.php
index d24c20588..bbf163def 100755
--- a/tests/Behat/Context/Ui/Shop/HomepageBlocksContext.php
+++ b/tests/Behat/Context/Ui/Shop/HomepageBlocksContext.php
@@ -18,14 +18,9 @@
final class HomepageBlocksContext implements Context
{
- /**
- * @var HomePageInterface
- */
+ /** @var HomePageInterface */
private $blockHomePage;
- /**
- * @param HomePageInterface $blockHomePage
- */
public function __construct(HomePageInterface $blockHomePage)
{
$this->blockHomePage = $blockHomePage;
diff --git a/tests/Behat/Context/Ui/Shop/PageContext.php b/tests/Behat/Context/Ui/Shop/PageContext.php
index 983aab05c..7e0835722 100755
--- a/tests/Behat/Context/Ui/Shop/PageContext.php
+++ b/tests/Behat/Context/Ui/Shop/PageContext.php
@@ -20,26 +20,15 @@
final class PageContext implements Context
{
- /**
- * @var ShowPageInterface
- */
+ /** @var ShowPageInterface */
private $showPage;
- /**
- * @var IndexPageInterface
- */
+ /** @var IndexPageInterface */
private $indexPage;
- /**
- * @var SharedStorageInterface
- */
+ /** @var SharedStorageInterface */
private $sharedStorage;
- /**
- * @param ShowPageInterface $showPage
- * @param IndexPageInterface $indexPage
- * @param SharedStorageInterface $sharedStorage
- */
public function __construct(
ShowPageInterface $showPage,
IndexPageInterface $indexPage,
diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php
index 7887f77cb..80494598a 100755
--- a/tests/Behat/Page/Admin/Block/CreatePage.php
+++ b/tests/Behat/Page/Admin/Block/CreatePage.php
@@ -14,6 +14,7 @@
use Behat\Mink\Driver\Selenium2Driver;
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
+use Tests\BitBag\SyliusCmsPlugin\Behat\Service\JQueryHelper;
use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait;
use Webmozart\Assert\Assert;
@@ -21,70 +22,42 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
{
use ContainsErrorTrait;
- /**
- * {@inheritdoc}
- */
- public function fillField(string $field, string $value): void
- {
- $this->getDocument()->fillField($field, $value);
- }
-
- /**
- * {@inheritdoc}
- */
public function fillCode(string $code): void
{
$this->getDocument()->fillField('Code', $code);
}
- /**
- * {@inheritdoc}
- */
public function uploadImage(string $image): void
{
$path = __DIR__ . '/../../../Resources/images/' . $image;
Assert::fileExists($path);
- $this->getDocument()
- ->attachFileToField('Choose file', $path);
+ $this->getDocument()->attachFileToField('Choose file', $path);
}
- /**
- * {@inheritdoc}
- */
public function fillName(string $name): void
{
$this->getDocument()->fillField('Name', $name);
}
- /**
- * {@inheritdoc}
- */
public function fillLink(string $link): void
{
$this->getDocument()->fillField('Link', $link);
}
- /**
- * {@inheritdoc}
- */
public function fillContent(string $content): void
{
- $this->getDocument()->fillField('Content', $content);
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
+ $this->getDocument()->find('.css','.ck_editable')->setValue($content);
}
- /**
- * {@inheritdoc}
- */
public function disable(): void
{
$this->getDocument()->uncheckField('Enabled');
}
- /**
- * {@inheritdoc}
- */
public function associateSections(array $sectionsNames): void
{
Assert::isInstanceOf($this->getDriver(), Selenium2Driver::class);
@@ -107,9 +80,6 @@ public function associateSections(array $sectionsNames): void
}
}
- /**
- * {@inheritdoc}
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Admin/Block/CreatePageInterface.php b/tests/Behat/Page/Admin/Block/CreatePageInterface.php
index e9326ece2..48b2b4476 100755
--- a/tests/Behat/Page/Admin/Block/CreatePageInterface.php
+++ b/tests/Behat/Page/Admin/Block/CreatePageInterface.php
@@ -17,40 +17,16 @@
interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInterface
{
- /**
- * @param string $label
- * @param string $value
- */
- public function fillField(string $label, string $value);
-
- /**
- * @param string $code
- */
public function fillCode(string $code): void;
- /**
- * @param string $image
- */
public function uploadImage(string $image): void;
- /**
- * @param string $name
- */
public function fillName(string $name): void;
- /**
- * @param string $link
- */
public function fillLink(string $link): void;
- /**
- * @param string $content
- */
public function fillContent(string $content): void;
- /**
- * @param array $sectionsNames
- */
public function associateSections(array $sectionsNames): void;
public function disable(): void;
diff --git a/tests/Behat/Page/Admin/Block/IndexPage.php b/tests/Behat/Page/Admin/Block/IndexPage.php
index 688d35c64..a1659370d 100755
--- a/tests/Behat/Page/Admin/Block/IndexPage.php
+++ b/tests/Behat/Page/Admin/Block/IndexPage.php
@@ -20,9 +20,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
{
use ContainsEmptyListTrait;
- /**
- * {@inheritdoc}
- */
public function getBlocksWithTypeCount(string $type): int
{
$tableAccessor = $this->getTableAccessor();
@@ -31,27 +28,8 @@ public function getBlocksWithTypeCount(string $type): int
return count($tableAccessor->getRowsWithFields($table, ['type' => $type]));
}
- /**
- * {@inheritdoc}
- */
public function deleteBlock(string $code): void
{
$this->deleteResourceOnPage(['code' => $code]);
}
-
- /**
- * {@inheritdoc}
- */
- public function getBlockTypes(): array
- {
- $blockTypes = $this->getDocument()->findAll('css', '#create-block-dropdown a');
- $result = [];
-
- /** @var NodeElement $blockType */
- foreach ($blockTypes as $blockType) {
- $result[] = $blockType->getText();
- }
-
- return $result;
- }
}
diff --git a/tests/Behat/Page/Admin/Block/IndexPageInterface.php b/tests/Behat/Page/Admin/Block/IndexPageInterface.php
index 9ec6ff453..4c06cfabe 100755
--- a/tests/Behat/Page/Admin/Block/IndexPageInterface.php
+++ b/tests/Behat/Page/Admin/Block/IndexPageInterface.php
@@ -17,20 +17,7 @@
interface IndexPageInterface extends BaseIndexPageInterface, ContainsEmptyListInterface
{
- /**
- * @param string $type
- *
- * @return int
- */
public function getBlocksWithTypeCount(string $type): int;
- /**
- * @param string $code
- */
public function deleteBlock(string $code): void;
-
- /**
- * @return array
- */
- public function getBlockTypes(): array;
}
diff --git a/tests/Behat/Page/Admin/Block/UpdatePage.php b/tests/Behat/Page/Admin/Block/UpdatePage.php
index bb6f8d55e..461cb81ee 100755
--- a/tests/Behat/Page/Admin/Block/UpdatePage.php
+++ b/tests/Behat/Page/Admin/Block/UpdatePage.php
@@ -13,6 +13,7 @@
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Block;
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
+use Tests\BitBag\SyliusCmsPlugin\Behat\Service\JQueryHelper;
use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ChecksCodeImmutabilityTrait;
use Webmozart\Assert\Assert;
@@ -20,17 +21,6 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
{
use ChecksCodeImmutabilityTrait;
- /**
- * {@inheritdoc}
- */
- public function fillField(string $field, string $value): void
- {
- $this->getDocument()->fillField($field, $value);
- }
-
- /**
- * {@inheritdoc}
- */
public function uploadImage(string $image): void
{
$path = __DIR__ . '/../../../Resources/images/' . $image;
@@ -40,41 +30,28 @@ public function uploadImage(string $image): void
$this->getDocument()->attachFileToField('Choose file', $path);
}
- /**
- * {@inheritdoc}
- */
public function fillName(string $name): void
{
$this->getDocument()->fillField('Name', $name);
}
- /**
- * {@inheritdoc}
- */
public function fillLink(string $link): void
{
$this->getDocument()->fillField('Link', $link);
}
- /**
- * {@inheritdoc}
- */
public function fillContent(string $content): void
{
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
$this->getDocument()->fillField('Content', $content);
}
- /**
- * {@inheritdoc}
- */
public function disable(): void
{
$this->getDocument()->uncheckField('Enabled');
}
- /**
- * {@inheritdoc}
- */
public function isBlockDisabled(): bool
{
return $this->getDocument()->findField('Enabled')->isChecked();
diff --git a/tests/Behat/Page/Admin/Block/UpdatePageInterface.php b/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
index 1e83b98df..9ee94ec7a 100755
--- a/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
+++ b/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
@@ -17,36 +17,15 @@
interface UpdatePageInterface extends BaseUpdatePageInterface, ChecksCodeImmutabilityInterface
{
- /**
- * @param string $field
- * @param string $value
- */
- public function fillField(string $field, string $value): void;
-
- /**
- * @param string $image
- */
public function uploadImage(string $image): void;
- /**
- * @param string $name
- */
public function fillName(string $name): void;
- /**
- * @param string $link
- */
public function fillLink(string $link): void;
- /**
- * @param string $content
- */
public function fillContent(string $content): void;
public function disable(): void;
- /**
- * @return bool
- */
public function isBlockDisabled(): bool;
}
diff --git a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePage.php b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePage.php
index 746718557..1881e1c88 100755
--- a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePage.php
+++ b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePage.php
@@ -13,49 +13,39 @@
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\FrequentlyAskedQuestion;
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
+use Tests\BitBag\SyliusCmsPlugin\Behat\Service\JQueryHelper;
use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait;
class CreatePage extends BaseCreatePage implements CreatePageInterface
{
use ContainsErrorTrait;
- /**
- * {@inheritdoc}
- */
public function fillField(string $field, string $value): void
{
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
$this->getDocument()->fillField($field, $value);
}
- /**
- * {@inheritdoc}
- */
public function fillCode(string $code): void
{
$this->getDocument()->fillField('Code', $code);
}
- /**
- * {@inheritdoc}
- */
public function setPosition(int $position): void
{
$this->getDocument()->fillField('Position', $position);
}
- /**
- * {@inheritdoc}
- */
public function fillQuestion(string $question): void
{
$this->getDocument()->fillField('Question', $question);
}
- /**
- * {@inheritdoc}
- */
public function fillAnswer(string $answer): void
{
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
$this->getDocument()->fillField('Answer', $answer);
}
}
diff --git a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePageInterface.php b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePageInterface.php
index 15976fd81..d2c460f52 100755
--- a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePageInterface.php
+++ b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/CreatePageInterface.php
@@ -17,29 +17,13 @@
interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInterface
{
- /**
- * @param string $label
- * @param string $value
- */
public function fillField(string $label, string $value): void;
- /**
- * @param string $code
- */
public function fillCode(string $code): void;
- /**
- * @param int $position
- */
public function setPosition(int $position): void;
- /**
- * @param string $question
- */
public function fillQuestion(string $question): void;
- /**
- * @param string $answer
- */
public function fillAnswer(string $answer): void;
}
diff --git a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPage.php b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPage.php
index 4caf97c63..4dd3e6205 100755
--- a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPage.php
+++ b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPage.php
@@ -19,9 +19,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
{
use ContainsEmptyListTrait;
- /**
- * {@inheritdoc}
- */
public function deleteFrequentlyAskedQuestion(string $code): void
{
$this->deleteResourceOnPage(['code' => $code]);
diff --git a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPageInterface.php b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPageInterface.php
index 8287c7f78..61d26f0ca 100755
--- a/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPageInterface.php
+++ b/tests/Behat/Page/Admin/FrequentlyAskedQuestion/IndexPageInterface.php
@@ -17,8 +17,5 @@
interface IndexPageInterface extends BaseIndexPageInterface, ContainsEmptyListInterface
{
- /**
- * @param string $code
- */
public function deleteFrequentlyAskedQuestion(string $code): void;
}
diff --git a/tests/Behat/Page/Admin/Media/CreatePage.php b/tests/Behat/Page/Admin/Media/CreatePage.php
index be8e14148..a9d673028 100755
--- a/tests/Behat/Page/Admin/Media/CreatePage.php
+++ b/tests/Behat/Page/Admin/Media/CreatePage.php
@@ -74,9 +74,6 @@ public function associateSections(array $sectionsNames): void
}
}
- /**
- * @return array
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Admin/Media/IndexPage.php b/tests/Behat/Page/Admin/Media/IndexPage.php
index 08f082554..5da0e164d 100755
--- a/tests/Behat/Page/Admin/Media/IndexPage.php
+++ b/tests/Behat/Page/Admin/Media/IndexPage.php
@@ -19,9 +19,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
{
use ContainsEmptyListTrait;
- /**
- * {@inheritdoc}
- */
public function deleteMedia(string $code): void
{
$this->deleteResourceOnPage(['code' => $code]);
diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php
index 9027c7a7a..de763503a 100755
--- a/tests/Behat/Page/Admin/Page/CreatePage.php
+++ b/tests/Behat/Page/Admin/Page/CreatePage.php
@@ -1,7 +1,7 @@
getSession());
+
$this->getDocument()->fillField($field, $value);
}
- /**
- * {@inheritdoc}
- */
public function uploadImage(string $image): void
{
$path = __DIR__ . '/../../../Resources/images/' . $image;
@@ -43,17 +40,11 @@ public function uploadImage(string $image): void
->attachFileToField('Choose file', $path);
}
- /**
- * {@inheritdoc}
- */
public function fillCode(string $code): void
{
$this->getDocument()->fillField('Code', $code);
}
- /**
- * {@inheritdoc}
- */
public function fillName(string $name): void
{
$this->getDocument()->fillField('Name', $name);
@@ -63,41 +54,28 @@ public function fillName(string $name): void
}
}
- /**
- * {@inheritdoc}
- */
public function fillSlug(string $slug): void
{
$this->getDocument()->fillField('Slug', $slug);
}
- /**
- * {@inheritdoc}
- */
public function fillMetaKeywords(string $metaKeywords): void
{
$this->getDocument()->fillField('Meta keywords', $metaKeywords);
}
- /**
- * {@inheritdoc}
- */
public function fillMetaDescription(string $metaDescription): void
{
$this->getDocument()->fillField('Meta description', $metaDescription);
}
- /**
- * {@inheritdoc}
- */
public function fillContent(string $content): void
{
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
$this->getDocument()->fillField('Content', $content);
}
- /**
- * {@inheritdoc}
- */
public function associateSections(array $sectionsNames): void
{
Assert::isInstanceOf($this->getDriver(), Selenium2Driver::class);
@@ -120,9 +98,6 @@ public function associateSections(array $sectionsNames): void
}
}
- /**
- * @return array
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Admin/Page/CreatePageInterface.php b/tests/Behat/Page/Admin/Page/CreatePageInterface.php
index 156746272..fd8b4fa11 100755
--- a/tests/Behat/Page/Admin/Page/CreatePageInterface.php
+++ b/tests/Behat/Page/Admin/Page/CreatePageInterface.php
@@ -17,49 +17,21 @@
interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInterface
{
- /**
- * @param string $field
- * @param string $value
- */
public function fillField(string $field, string $value): void;
- /**
- * @param string $image
- */
public function uploadImage(string $image): void;
- /**
- * @param string $code
- */
public function fillCode(string $code): void;
- /**
- * @param string $name
- */
public function fillName(string $name): void;
- /**
- * @param string $slug
- */
public function fillSlug(string $slug): void;
- /**
- * @param string $metaKeywords
- */
public function fillMetaKeywords(string $metaKeywords): void;
- /**
- * @param string $metaDescription
- */
public function fillMetaDescription(string $metaDescription): void;
- /**
- * @param string $content
- */
public function fillContent(string $content): void;
- /**
- * @param array $sectionsNames
- */
public function associateSections(array $sectionsNames): void;
}
diff --git a/tests/Behat/Page/Admin/Page/IndexPage.php b/tests/Behat/Page/Admin/Page/IndexPage.php
index 94b39e6a5..04fda6b02 100755
--- a/tests/Behat/Page/Admin/Page/IndexPage.php
+++ b/tests/Behat/Page/Admin/Page/IndexPage.php
@@ -19,9 +19,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
{
use ContainsEmptyListTrait;
- /**
- * {@inheritdoc}
- */
public function deletePage(string $code): void
{
$this->deleteResourceOnPage(['code' => $code]);
diff --git a/tests/Behat/Page/Admin/Page/IndexPageInterface.php b/tests/Behat/Page/Admin/Page/IndexPageInterface.php
index 9068bea98..39dfc10be 100755
--- a/tests/Behat/Page/Admin/Page/IndexPageInterface.php
+++ b/tests/Behat/Page/Admin/Page/IndexPageInterface.php
@@ -17,8 +17,5 @@
interface IndexPageInterface extends BaseIndexPageInterface, ContainsEmptyListInterface
{
- /**
- * @param string $code
- */
public function deletePage(string $code): void;
}
diff --git a/tests/Behat/Page/Admin/Page/UpdatePage.php b/tests/Behat/Page/Admin/Page/UpdatePage.php
index f394361d5..0b537ed58 100755
--- a/tests/Behat/Page/Admin/Page/UpdatePage.php
+++ b/tests/Behat/Page/Admin/Page/UpdatePage.php
@@ -13,6 +13,7 @@
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Page;
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
+use Tests\BitBag\SyliusCmsPlugin\Behat\Service\JQueryHelper;
use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ChecksCodeImmutabilityTrait;
use Webmozart\Assert\Assert;
@@ -20,17 +21,13 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
{
use ChecksCodeImmutabilityTrait;
- /**
- * {@inheritdoc}
- */
public function fillField(string $field, string $value): void
{
+ JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
+
$this->getDocument()->fillField($field, $value);
}
- /**
- * {@inheritdoc}
- */
public function uploadImage(string $image): void
{
$path = __DIR__ . '/../../../Resources/images/' . $image;
diff --git a/tests/Behat/Page/Admin/Page/UpdatePageInterface.php b/tests/Behat/Page/Admin/Page/UpdatePageInterface.php
index 8f1153321..6f6783ab2 100755
--- a/tests/Behat/Page/Admin/Page/UpdatePageInterface.php
+++ b/tests/Behat/Page/Admin/Page/UpdatePageInterface.php
@@ -17,8 +17,5 @@
interface UpdatePageInterface extends BaseUpdatePageInterface, ChecksCodeImmutabilityInterface
{
- /**
- * @param string $image
- */
public function uploadImage(string $image): void;
}
diff --git a/tests/Behat/Page/Admin/Section/CreatePage.php b/tests/Behat/Page/Admin/Section/CreatePage.php
index b17a14dab..f497fc7aa 100755
--- a/tests/Behat/Page/Admin/Section/CreatePage.php
+++ b/tests/Behat/Page/Admin/Section/CreatePage.php
@@ -19,25 +19,16 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
{
use ContainsErrorTrait;
- /**
- * {@inheritdoc}
- */
public function fillField(string $field, string $value): void
{
$this->getDocument()->fillField($field, $value);
}
- /**
- * {@inheritdoc}
- */
public function fillCode(string $code): void
{
$this->getDocument()->fillField('Code', $code);
}
- /**
- * {@inheritdoc}
- */
public function fillName(string $name): void
{
$this->getDocument()->fillField('Name', $name);
diff --git a/tests/Behat/Page/Admin/Section/CreatePageInterface.php b/tests/Behat/Page/Admin/Section/CreatePageInterface.php
index e1e02ab01..3180a479d 100755
--- a/tests/Behat/Page/Admin/Section/CreatePageInterface.php
+++ b/tests/Behat/Page/Admin/Section/CreatePageInterface.php
@@ -17,19 +17,9 @@
interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInterface
{
- /**
- * @param string $field
- * @param string $value
- */
public function fillField(string $field, string $value): void;
- /**
- * @param string $code
- */
public function fillCode(string $code): void;
- /**
- * @param string $name
- */
public function fillName(string $name): void;
}
diff --git a/tests/Behat/Page/Admin/Section/IndexPage.php b/tests/Behat/Page/Admin/Section/IndexPage.php
index 51af47991..e4a587710 100755
--- a/tests/Behat/Page/Admin/Section/IndexPage.php
+++ b/tests/Behat/Page/Admin/Section/IndexPage.php
@@ -19,9 +19,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
{
use ContainsEmptyListTrait;
- /**
- * {@inheritdoc}
- */
public function deleteSection(string $code): void
{
$this->deleteResourceOnPage(['code' => $code]);
diff --git a/tests/Behat/Page/Admin/Section/IndexPageInterface.php b/tests/Behat/Page/Admin/Section/IndexPageInterface.php
index 2143d2b4d..358381dc0 100755
--- a/tests/Behat/Page/Admin/Section/IndexPageInterface.php
+++ b/tests/Behat/Page/Admin/Section/IndexPageInterface.php
@@ -17,8 +17,5 @@
interface IndexPageInterface extends BaseIndexPageInterface, ContainsEmptyListInterface
{
- /**
- * @param string $code
- */
public function deleteSection(string $code): void;
}
diff --git a/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPage.php b/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPage.php
index eb0b10bc6..3cf5f2882 100755
--- a/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPage.php
+++ b/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPage.php
@@ -16,17 +16,11 @@
final class IndexPage extends SymfonyPage implements IndexPageInterface
{
- /**
- * {@inheritdoc}
- */
public function getRouteName(): string
{
return 'bitbag_sylius_cms_plugin_shop_frequently_asked_question_index';
}
- /**
- * {@inheritdoc}
- */
public function hasFrequentlyAskedQuestionsNumber(int $number): bool
{
$frequentlyAskedQuestionsOnPage = $this->getElement('faqs')->findAll('css', '.bitbag-question');
@@ -34,9 +28,6 @@ public function hasFrequentlyAskedQuestionsNumber(int $number): bool
return $number === count($frequentlyAskedQuestionsOnPage);
}
- /**
- * {@inheritdoc}
- */
public function hasQuestionWithPositionPrefixAtValidIndex(int $position): bool
{
$frequentlyAskedQuestionsOnPage = $this->getElement('faqs')->findAll('css', '.bitbag-question');
@@ -59,9 +50,6 @@ public function hasQuestionWithPositionPrefixAtValidIndex(int $position): bool
return false;
}
- /**
- * {@inheritdoc}
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPageInterface.php b/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPageInterface.php
index 6eedc1267..c689b3f07 100755
--- a/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPageInterface.php
+++ b/tests/Behat/Page/Shop/FrequentlyAskedQuestion/IndexPageInterface.php
@@ -16,17 +16,7 @@
interface IndexPageInterface extends SymfonyPageInterface
{
- /**
- * @param int $number
- *
- * @return bool
- */
public function hasFrequentlyAskedQuestionsNumber(int $number): bool;
- /**
- * @param int $position
- *
- * @return bool
- */
public function hasQuestionWithPositionPrefixAtValidIndex(int $position): bool;
}
diff --git a/tests/Behat/Page/Shop/HomePage.php b/tests/Behat/Page/Shop/HomePage.php
index c96704d9b..982ae77c3 100755
--- a/tests/Behat/Page/Shop/HomePage.php
+++ b/tests/Behat/Page/Shop/HomePage.php
@@ -16,25 +16,16 @@
class HomePage extends BaseHomePage implements HomePageInterface
{
- /**
- * {@inheritdoc}
- */
public function hasImageBlock(): bool
{
return $this->getElement('image_block')->has('css', 'img');
}
- /**
- * {@inheritdoc}
- */
public function hasBlockWithContent(string $content): bool
{
return $content === $this->getElement('content')->getText();
}
- /**
- * {@inheritdoc}
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Shop/HomePageInterface.php b/tests/Behat/Page/Shop/HomePageInterface.php
index 530cbacfa..24f52e06c 100755
--- a/tests/Behat/Page/Shop/HomePageInterface.php
+++ b/tests/Behat/Page/Shop/HomePageInterface.php
@@ -16,15 +16,7 @@
interface HomePageInterface extends BaseHomePageInterface
{
- /**
- * @return bool
- */
public function hasImageBlock(): bool;
- /**
- * @param string $content
- *
- * @return bool
- */
public function hasBlockWithContent(string $content): bool;
}
diff --git a/tests/Behat/Page/Shop/Page/IndexPage.php b/tests/Behat/Page/Shop/Page/IndexPage.php
index f9912e9a8..00a824f5e 100755
--- a/tests/Behat/Page/Shop/Page/IndexPage.php
+++ b/tests/Behat/Page/Shop/Page/IndexPage.php
@@ -16,25 +16,16 @@
final class IndexPage extends SymfonyPage implements IndexPageInterface
{
- /**
- * {@inheritdoc}
- */
public function getRouteName(): string
{
return 'bitbag_sylius_cms_plugin_shop_page_index_by_section_code';
}
- /**
- * {@inheritdoc}
- */
public function hasSectionName(string $sectionName): bool
{
return $sectionName === $this->getElement('section')->getText();
}
- /**
- * {@inheritdoc}
- */
public function hasPagesNumber(int $pagesNumber): bool
{
$pagesNumberOnPage = count($this->getElement('pages')->findAll('css', '.bitbag-page'));
@@ -42,9 +33,6 @@ public function hasPagesNumber(int $pagesNumber): bool
return $pagesNumber === $pagesNumberOnPage;
}
- /**
- * {@inheritdoc}
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Shop/Page/IndexPageInterface.php b/tests/Behat/Page/Shop/Page/IndexPageInterface.php
index 4767b54f5..d2ecd2c5d 100755
--- a/tests/Behat/Page/Shop/Page/IndexPageInterface.php
+++ b/tests/Behat/Page/Shop/Page/IndexPageInterface.php
@@ -16,17 +16,7 @@
interface IndexPageInterface extends SymfonyPageInterface
{
- /**
- * @param string $sectionName
- *
- * @return bool
- */
public function hasSectionName(string $sectionName): bool;
- /**
- * @param int $pagesNumber
- *
- * @return bool
- */
public function hasPagesNumber(int $pagesNumber): bool;
}
diff --git a/tests/Behat/Page/Shop/Page/ShowPage.php b/tests/Behat/Page/Shop/Page/ShowPage.php
index 3fb0a9d31..d983cee9a 100755
--- a/tests/Behat/Page/Shop/Page/ShowPage.php
+++ b/tests/Behat/Page/Shop/Page/ShowPage.php
@@ -17,33 +17,21 @@
final class ShowPage extends SymfonyPage implements ShowPageInterface
{
- /**
- * {@inheritdoc}
- */
public function getRouteName(): string
{
return 'bitbag_sylius_cms_plugin_shop_page_show';
}
- /**
- * {@inheritdoc}
- */
public function hasName(string $name): bool
{
return $name === $this->getElement('name')->getText();
}
- /**
- * {@inheritdoc}
- */
public function hasContent(string $content): bool
{
return $content === $this->getElement('content')->getText();
}
- /**
- * {@inheritdoc}
- */
public function hasProducts(array $productsNames): bool
{
$productsOnPage = $this->getElement('products')->findAll('css', '.sylius-product-name');
@@ -58,9 +46,6 @@ public function hasProducts(array $productsNames): bool
return true;
}
- /**
- * {@inheritdoc}
- */
public function hasSections(array $sectionNames): bool
{
$sectionsOnPage = $this->getElement('sections')->findAll('css', 'a');
@@ -75,25 +60,16 @@ public function hasSections(array $sectionNames): bool
return true;
}
- /**
- * {@inheritdoc}
- */
public function hasPageLink(string $linkName): bool
{
return $linkName === $this->getElement('link')->getText();
}
- /**
- * {@inheritdoc}
- */
public function hasPageImage(): bool
{
return $this->getElement('page-image')->isVisible();
}
- /**
- * {@inheritdoc}
- */
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
diff --git a/tests/Behat/Page/Shop/Page/ShowPageInterface.php b/tests/Behat/Page/Shop/Page/ShowPageInterface.php
index 49cb1257e..d133d8b11 100755
--- a/tests/Behat/Page/Shop/Page/ShowPageInterface.php
+++ b/tests/Behat/Page/Shop/Page/ShowPageInterface.php
@@ -16,43 +16,15 @@
interface ShowPageInterface extends SymfonyPageInterface
{
- /**
- * @param string $name
- *
- * @return bool
- */
public function hasName(string $name): bool;
- /**
- * @param string $content
- *
- * @return bool
- */
public function hasContent(string $content): bool;
- /**
- * @param array $productsNames
- *
- * @return bool
- */
public function hasProducts(array $productsNames): bool;
- /**
- * @param array $sectionNames
- *
- * @return bool
- */
public function hasSections(array $sectionNames): bool;
- /**
- * @param string $linkName
- *
- * @return bool
- */
public function hasPageLink(string $linkName): bool;
- /**
- * @return bool
- */
public function hasPageImage(): bool;
}
diff --git a/tests/Behat/Resources/services/contexts.yml b/tests/Behat/Resources/services/contexts.yml
index a77f85ade..c6beae021 100755
--- a/tests/Behat/Resources/services/contexts.yml
+++ b/tests/Behat/Resources/services/contexts.yml
@@ -1,3 +1,3 @@
imports:
- - { resource: "contexts/setup.yml" }
- - { resource: "contexts/ui.yml" }
+ - { resource: contexts/setup.yml }
+ - { resource: contexts/ui.yml }
diff --git a/tests/Behat/Resources/services/contexts/setup.yml b/tests/Behat/Resources/services/contexts/setup.yml
index 26a603897..3974e7f17 100755
--- a/tests/Behat/Resources/services/contexts/setup.yml
+++ b/tests/Behat/Resources/services/contexts/setup.yml
@@ -6,7 +6,6 @@ services:
- "@bitbag_sylius_cms_plugin.behat.random_string_generator"
- "@__symfony__.bitbag_sylius_cms_plugin.factory.block"
- "@__symfony__.bitbag_sylius_cms_plugin.repository.block"
- - "@__symfony__.sylius.image_uploader"
tags:
- { name: fob.context_service }
diff --git a/tests/Behat/Service/JQueryHelper.php b/tests/Behat/Service/JQueryHelper.php
new file mode 100644
index 000000000..eff38a97f
--- /dev/null
+++ b/tests/Behat/Service/JQueryHelper.php
@@ -0,0 +1,26 @@
+getDriver() instanceof Selenium2Driver) {
+ $session->wait(5000, '0 === jQuery.active');
+ }
+ }
+}
diff --git a/tests/Behat/Service/RandomStringGenerator.php b/tests/Behat/Service/RandomStringGenerator.php
index a11435963..803ee5e53 100755
--- a/tests/Behat/Service/RandomStringGenerator.php
+++ b/tests/Behat/Service/RandomStringGenerator.php
@@ -1,6 +1,5 @@
daily
0.7
-
\ No newline at end of file
+
diff --git a/tests/Responses/Expected/show_sitemap_pages_locale.xml b/tests/Responses/Expected/show_sitemap_pages_locale.xml
index a1302e712..0c4855759 100644
--- a/tests/Responses/Expected/show_sitemap_pages_locale.xml
+++ b/tests/Responses/Expected/show_sitemap_pages_locale.xml
@@ -32,4 +32,4 @@
daily
0.7
-
\ No newline at end of file
+