diff --git a/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php b/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php index aea36cb6..3b39af8f 100644 --- a/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php +++ b/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php @@ -23,9 +23,6 @@ public function __construct(private MediaRepositoryInterface $mediaRepository) { } - /** - * @throws \InvalidArgumentException - */ public function transform($value): Collection { Assert::nullOrIsArray($value); @@ -37,9 +34,6 @@ public function transform($value): Collection return new ArrayCollection($this->mediaRepository->findBy(['code' => $value])); } - /** - * @throws \InvalidArgumentException - */ public function reverseTransform($value): array { Assert::isInstanceOf($value, Collection::class); diff --git a/src/Form/Type/ContentConfigurationType.php b/src/Form/Type/ContentConfigurationType.php index 5ba70591..ead59d4e 100644 --- a/src/Form/Type/ContentConfigurationType.php +++ b/src/Form/Type/ContentConfigurationType.php @@ -51,11 +51,16 @@ public function buildForm(FormBuilderInterface $builder, array $options): void return [ 'data-configuration' => $this->twig->render( '@BitBagSyliusCmsPlugin/ContentConfiguration/_action.html.twig', - ['field' => $builder->create( - 'configuration', - $this->actionConfigurationTypes[$type], - ['label' => false, 'csrf_protection' => false], - )->getForm()->createView()], + [ + 'field' => $builder->create( + 'configuration', + $this->actionConfigurationTypes[$type], + [ + 'label' => false, + 'csrf_protection' => false, + ], + )->getForm()->createView(), + ], ), ]; }, diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 4df1b3a6..0c5f534c 100644 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -74,40 +74,40 @@ - + - + - + - + - + - + - + diff --git a/tests/Behat/Behaviour/ContainsContentElementTrait.php b/tests/Behat/Behaviour/ContainsContentElementTrait.php index 3cc68547..db6e686e 100644 --- a/tests/Behat/Behaviour/ContainsContentElementTrait.php +++ b/tests/Behat/Behaviour/ContainsContentElementTrait.php @@ -34,8 +34,6 @@ public function containsContentElement(string $contentElement): bool throw new \InvalidArgumentException('Content elements container not found.'); } - // Autocomplete fields doesn't have labels directly above input field, so we can't use hasField method, - // so we need to check if input field with search class exists instead. return $isAutocompleteField ? $contentElements->has('css', 'input.search') : $contentElements->hasField($contentElement); diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index 4a4a2f66..7af9cc02 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -10,7 +10,6 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Block; -use Behat\Mink\Exception\ElementNotFoundException; use DMore\ChromeDriver\ChromeDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; @@ -66,7 +65,7 @@ public function associateCollections(array $collectionsNames): void $dropdown->click(); foreach ($collectionsNames as $collectionName) { - $dropdown->waitFor(10, function () use ($collectionName): bool { + $dropdown->waitFor(5, function () use ($collectionName): bool { return $this->hasElement('association_dropdown_collection_item', [ '%item%' => $collectionName, ]); @@ -80,9 +79,6 @@ public function associateCollections(array $collectionsNames): void } } - /** - * @throws ElementNotFoundException - */ public function clickOnAddContentElementButton(): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); @@ -90,30 +86,24 @@ public function clickOnAddContentElementButton(): void $addButton = $this->getElement('content_elements_add_button'); $addButton->click(); - $addButton->waitFor(3, function (): bool { + $addButton->waitFor(1, function (): bool { return $this->hasElement('content_elements_select_type'); }); } - /** - * @throws ElementNotFoundException - */ public function selectContentElement(string $contentElement): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); $select = $this->getElement('content_elements_select_type'); $select->selectOption($contentElement); - $select->waitFor(3, function () use ($contentElement): bool { + $select->waitFor(1, function () use ($contentElement): bool { return $this->hasElement( ContentElementHelper::getDefinedElementThatShouldAppearAfterSelectContentElement($contentElement), ); }); } - /** - * @throws ElementNotFoundException - */ public function addTextareaContentElementWithContent(string $content): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); @@ -122,15 +112,12 @@ public function addTextareaContentElementWithContent(string $content): void $textarea->setValue($content); } - /** - * @throws ElementNotFoundException - */ public function addSingleMediaContentElementWithName(string $name): void { $dropdown = $this->getElement('content_elements_single_media_dropdown'); $dropdown->click(); - $dropdown->waitFor(10, function () use ($name): bool { + $dropdown->waitFor(5, function () use ($name): bool { return $this->hasElement('content_elements_single_media_dropdown_item', [ '%item%' => $name, ]); @@ -143,16 +130,13 @@ public function addSingleMediaContentElementWithName(string $name): void $item->click(); } - /** - * @throws ElementNotFoundException - */ public function addMultipleMediaContentElementWithNames(array $mediaNames): void { $dropdown = $this->getElement('content_elements_multiple_media_dropdown'); $dropdown->click(); foreach ($mediaNames as $mediaName) { - $dropdown->waitFor(10, function () use ($mediaName): bool { + $dropdown->waitFor(5, function () use ($mediaName): bool { return $this->hasElement('content_elements_multiple_media_dropdown_item', [ '%item%' => $mediaName, ]); @@ -166,9 +150,6 @@ public function addMultipleMediaContentElementWithNames(array $mediaNames): void } } - /** - * @throws ElementNotFoundException - */ public function addHeadingContentElementWithTypeAndContent(string $type, string $content): void { $heading = $this->getElement('content_elements_heading'); @@ -178,16 +159,13 @@ public function addHeadingContentElementWithTypeAndContent(string $type, string $headingContent->setValue($content); } - /** - * @throws ElementNotFoundException - */ public function addProductsCarouselContentElementWithProducts(array $productsNames): void { $dropdown = $this->getElement('content_elements_products_carousel'); $dropdown->click(); foreach ($productsNames as $productName) { - $dropdown->waitFor(10, function () use ($productName): bool { + $dropdown->waitFor(5, function () use ($productName): bool { return $this->hasElement('content_elements_products_carousel_item', [ '%item%' => $productName, ]); @@ -201,15 +179,12 @@ public function addProductsCarouselContentElementWithProducts(array $productsNam } } - /** - * @throws ElementNotFoundException - */ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon): void { $dropdown = $this->getElement('content_elements_products_carousel_by_taxon'); $dropdown->click(); - $dropdown->waitFor(10, function () use ($taxon): bool { + $dropdown->waitFor(5, function () use ($taxon): bool { return $this->hasElement('content_elements_products_carousel_by_taxon_item', [ '%item%' => $taxon, ]); @@ -222,16 +197,13 @@ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon) $item->click(); } - /** - * @throws ElementNotFoundException - */ public function addTaxonsListContentElementWithTaxons(array $taxons): void { $dropdown = $this->getElement('content_elements_taxons_list'); $dropdown->click(); foreach ($taxons as $taxon) { - $dropdown->waitFor(10, function () use ($taxon): bool { + $dropdown->waitFor(5, function () use ($taxon): bool { return $this->hasElement('content_elements_taxons_list_item', [ '%item%' => $taxon, ]); diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php index 2771612a..c2eedbb3 100755 --- a/tests/Behat/Page/Admin/Page/CreatePage.php +++ b/tests/Behat/Page/Admin/Page/CreatePage.php @@ -10,7 +10,6 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Page; -use Behat\Mink\Exception\ElementNotFoundException; use DMore\ChromeDriver\ChromeDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Sylius\Behat\Service\SlugGenerationHelper; @@ -75,7 +74,7 @@ public function associateCollections(array $collectionsNames): void $dropdown->click(); foreach ($collectionsNames as $collectionName) { - $dropdown->waitFor(10, function () use ($collectionName): bool { + $dropdown->waitFor(5, function () use ($collectionName): bool { return $this->hasElement('association_dropdown_collection_item', [ '%item%' => $collectionName, ]); @@ -89,9 +88,6 @@ public function associateCollections(array $collectionsNames): void } } - /** - * @throws ElementNotFoundException - */ public function clickOnAddContentElementButton(): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); @@ -99,30 +95,24 @@ public function clickOnAddContentElementButton(): void $addButton = $this->getElement('content_elements_add_button'); $addButton->click(); - $addButton->waitFor(2, function (): bool { + $addButton->waitFor(1, function (): bool { return $this->hasElement('content_elements_select_type'); }); } - /** - * @throws ElementNotFoundException - */ public function selectContentElement(string $contentElement): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); $select = $this->getElement('content_elements_select_type'); $select->selectOption($contentElement); - $select->waitFor(3, function () use ($contentElement): bool { + $select->waitFor(1, function () use ($contentElement): bool { return $this->hasElement( ContentElementHelper::getDefinedElementThatShouldAppearAfterSelectContentElement($contentElement), ); }); } - /** - * @throws ElementNotFoundException - */ public function addTextareaContentElementWithContent(string $content): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); @@ -131,15 +121,12 @@ public function addTextareaContentElementWithContent(string $content): void $textarea->setValue($content); } - /** - * @throws ElementNotFoundException - */ public function addSingleMediaContentElementWithName(string $name): void { $dropdown = $this->getElement('content_elements_single_media_dropdown'); $dropdown->click(); - $dropdown->waitFor(10, function () use ($name): bool { + $dropdown->waitFor(5, function () use ($name): bool { return $this->hasElement('content_elements_single_media_dropdown_item', [ '%item%' => $name, ]); @@ -152,16 +139,13 @@ public function addSingleMediaContentElementWithName(string $name): void $item->click(); } - /** - * @throws ElementNotFoundException - */ public function addMultipleMediaContentElementWithNames(array $mediaNames): void { $dropdown = $this->getElement('content_elements_multiple_media_dropdown'); $dropdown->click(); foreach ($mediaNames as $mediaName) { - $dropdown->waitFor(10, function () use ($mediaName): bool { + $dropdown->waitFor(5, function () use ($mediaName): bool { return $this->hasElement('content_elements_multiple_media_dropdown_item', [ '%item%' => $mediaName, ]); @@ -175,9 +159,6 @@ public function addMultipleMediaContentElementWithNames(array $mediaNames): void } } - /** - * @throws ElementNotFoundException - */ public function addHeadingContentElementWithTypeAndContent(string $type, string $content): void { $heading = $this->getElement('content_elements_heading'); @@ -187,16 +168,13 @@ public function addHeadingContentElementWithTypeAndContent(string $type, string $headingContent->setValue($content); } - /** - * @throws ElementNotFoundException - */ public function addProductsCarouselContentElementWithProducts(array $productsNames): void { $dropdown = $this->getElement('content_elements_products_carousel'); $dropdown->click(); foreach ($productsNames as $productName) { - $dropdown->waitFor(10, function () use ($productName): bool { + $dropdown->waitFor(5, function () use ($productName): bool { return $this->hasElement('content_elements_products_carousel_item', [ '%item%' => $productName, ]); @@ -210,15 +188,12 @@ public function addProductsCarouselContentElementWithProducts(array $productsNam } } - /** - * @throws ElementNotFoundException - */ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon): void { $dropdown = $this->getElement('content_elements_products_carousel_by_taxon'); $dropdown->click(); - $dropdown->waitFor(10, function () use ($taxon): bool { + $dropdown->waitFor(5, function () use ($taxon): bool { return $this->hasElement('content_elements_products_carousel_by_taxon_item', [ '%item%' => $taxon, ]); @@ -231,16 +206,13 @@ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon) $item->click(); } - /** - * @throws ElementNotFoundException - */ public function addTaxonsListContentElementWithTaxons(array $taxons): void { $dropdown = $this->getElement('content_elements_taxons_list'); $dropdown->click(); foreach ($taxons as $taxon) { - $dropdown->waitFor(10, function () use ($taxon): bool { + $dropdown->waitFor(5, function () use ($taxon): bool { return $this->hasElement('content_elements_taxons_list_item', [ '%item%' => $taxon, ]);