diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02f8c524b..0a291efef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -168,6 +168,10 @@ jobs: name: Run PHPSpec run: vendor/bin/phpspec run --ansi -f progress --no-interaction + - + name: Run PHPUnit + run: vendor/bin/phpunit --colors=always + - name: Run Behat run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun diff --git a/composer.json b/composer.json index 23175c3de..82f2de24b 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require-dev": { "behat/behat": "^3.7", "behat/mink-selenium2-driver": "^1.4", - "bitbag/coding-standard": "^1.0", + "bitbag/coding-standard": "^2.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", @@ -33,10 +33,10 @@ "lchrusciel/api-test-case": "^4.1 || ^5.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-doctrine": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^9.5", "sylius-labs/coding-standard": "^4.0", "symfony/browser-kit": "^5.4 || ^6.0", diff --git a/easy-coding-standard.yml b/easy-coding-standard.yml deleted file mode 100644 index 240359952..000000000 --- a/easy-coding-standard.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' } diff --git a/ecs.php b/ecs.php index b088160e3..022736f6b 100644 --- a/ecs.php +++ b/ecs.php @@ -2,13 +2,13 @@ declare(strict_types=1); -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\ValueObject\Option; -return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php'); +return static function (ECSConfig $config): void { + $config->import('vendor/bitbag/coding-standard/ecs.php'); - $parameters = $containerConfigurator->parameters(); + $parameters = $config->parameters(); $parameters->set(Option::PATHS, [ __DIR__ . '/src', __DIR__ . '/tests', diff --git a/phpstan.neon b/phpstan.neon index 209d86ad9..0c2a35c3c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ includes: - vendor/bitbag/coding-standard/phpstan.neon parameters: + level: 8 reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false diff --git a/spec/Assigner/ChannelsAssignerSpec.php b/spec/Assigner/ChannelsAssignerSpec.php index e8ab0b882..3bcb6e409 100644 --- a/spec/Assigner/ChannelsAssignerSpec.php +++ b/spec/Assigner/ChannelsAssignerSpec.php @@ -1,5 +1,7 @@ beConstructedWith($channelRepository); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ChannelsAssigner::class); } - function it_implements_channels_assigner_interface(): void + public function it_implements_channels_assigner_interface(): void { $this->shouldHaveType(ChannelsAssignerInterface::class); } - function it_assigns_channels( + public function it_assigns_channels( ChannelRepositoryInterface $channelRepository, ChannelInterface $webChannel, ChannelInterface $posChannel, ChannelsAwareInterface $channelsAware - ): void - { + ): void { $channelRepository->findOneBy(['code' => 'web'])->willReturn($webChannel); $channelRepository->findOneBy(['code' => 'pos'])->willReturn($posChannel); diff --git a/spec/Assigner/ProductsAssignerSpec.php b/spec/Assigner/ProductsAssignerSpec.php index 20e7db858..e1b999612 100644 --- a/spec/Assigner/ProductsAssignerSpec.php +++ b/spec/Assigner/ProductsAssignerSpec.php @@ -1,5 +1,7 @@ beConstructedWith($productRepository); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ProductsAssigner::class); } - function it_implements_products_assigner_interface(): void + public function it_implements_products_assigner_interface(): void { $this->shouldHaveType(ProductsAssignerInterface::class); } - function it_assigns_products( + public function it_assigns_products( ProductRepositoryInterface $productRepository, ProductInterface $mugProduct, ProductInterface $tshirtProduct, ProductsAwareInterface $productsAware - ): void - { + ): void { $productRepository->findOneBy(['code' => 'mug'])->willReturn($mugProduct); $productRepository->findOneBy(['code' => 't-shirt'])->willReturn($tshirtProduct); diff --git a/spec/Assigner/SectionsAssignerSpec.php b/spec/Assigner/SectionsAssignerSpec.php index 5fa30e7d8..1f26784cd 100644 --- a/spec/Assigner/SectionsAssignerSpec.php +++ b/spec/Assigner/SectionsAssignerSpec.php @@ -1,5 +1,7 @@ beConstructedWith($sectionRepository); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(SectionsAssigner::class); } - function it_implements_sections_assigner_interface(): void + public function it_implements_sections_assigner_interface(): void { $this->shouldHaveType(SectionsAssignerInterface::class); } - function it_assigns_sections( + public function it_assigns_sections( SectionRepositoryInterface $sectionRepository, SectionInterface $aboutSection, SectionInterface $blogSection, SectionableInterface $sectionsAware - ): void - { + ): void { $sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection); $sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection); diff --git a/spec/Assigner/TaxonsAssignerSpec.php b/spec/Assigner/TaxonsAssignerSpec.php index d01d17516..7eade976e 100644 --- a/spec/Assigner/TaxonsAssignerSpec.php +++ b/spec/Assigner/TaxonsAssignerSpec.php @@ -1,5 +1,7 @@ beConstructedWith($taxonRepository); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(TaxonsAssigner::class); } - function it_implements_taxons_assigner_interface(): void + public function it_implements_taxons_assigner_interface(): void { $this->shouldHaveType(TaxonsAssignerInterface::class); } - function it_assigns_taxons( + public function it_assigns_taxons( TaxonRepositoryInterface $taxonRepository, TaxonInterface $mugsTaxon, TaxonInterface $stickersTaxon, TaxonAwareInterface $taxonsAware - ): void - { + ): void { $taxonRepository->findOneBy(['code' => 'mugs'])->willReturn($mugsTaxon); $taxonRepository->findOneBy(['code' => 'stickers'])->willReturn($stickersTaxon); diff --git a/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php b/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php index ca989537f..380016d16 100644 --- a/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php +++ b/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php @@ -23,7 +23,7 @@ final class UploadEditorImageActionSpec extends ObjectBehavior { - function let( + public function let( MediaProviderResolverInterface $mediaProviderResolver, MediaRepositoryInterface $mediaRepository, FactoryInterface $mediaFactory @@ -31,12 +31,12 @@ function let( $this->beConstructedWith($mediaProviderResolver, $mediaRepository, $mediaFactory); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(UploadEditorImageAction::class); } - function it_uploads_media( + public function it_uploads_media( Request $request, FactoryInterface $mediaFactory, MediaInterface $media, diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php index a3997e3fe..782b9f5e0 100755 --- a/spec/Entity/BlockSpec.php +++ b/spec/Entity/BlockSpec.php @@ -21,22 +21,22 @@ final class BlockSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(Block::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_block_interface(): void + public function it_implements_block_interface(): void { $this->shouldHaveType(BlockInterface::class); } - function it_toggles(): void + public function it_toggles(): void { $this->enable(); $this->isEnabled()->shouldReturn(true); @@ -45,7 +45,7 @@ function it_toggles(): void $this->isEnabled()->shouldReturn(false); } - function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void + public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void { $this->addProduct($firstProduct); $this->hasProduct($firstProduct)->shouldReturn(true); @@ -57,7 +57,7 @@ function it_associates_products(ProductInterface $firstProduct, ProductInterface $this->hasProduct($firstProduct)->shouldReturn(false); } - function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void { $this->addSection($firstSection); $this->hasSection($firstSection)->shouldReturn(true); @@ -69,7 +69,7 @@ function it_associates_sections(SectionInterface $firstSection, SectionInterface $this->hasSection($firstSection)->shouldReturn(false); } - function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void + public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void { $this->addChannel($firstChannel); $this->hasChannel($firstChannel)->shouldReturn(true); @@ -81,7 +81,7 @@ function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $this->hasChannel($firstChannel)->shouldReturn(false); } - function it_associates_taxons(TaxonInterface $firstTaxon, TaxonInterface $secondTaxon): void + public function it_associates_taxons(TaxonInterface $firstTaxon, TaxonInterface $secondTaxon): void { $this->addTaxon($firstTaxon); $this->hasTaxon($firstTaxon)->shouldReturn(true); diff --git a/spec/Entity/BlockTranslationSpec.php b/spec/Entity/BlockTranslationSpec.php index e9115c827..2bc57c894 100755 --- a/spec/Entity/BlockTranslationSpec.php +++ b/spec/Entity/BlockTranslationSpec.php @@ -17,23 +17,23 @@ final class BlockTranslationSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_block_translation_interface(): void + public function it_implements_block_translation_interface(): void { $this->shouldHaveType(BlockTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties(): void + public function it_allows_access_via_properties(): void { $this->setName('Escobar favorite quote'); $this->getName()->shouldReturn('Escobar favorite quote'); diff --git a/spec/Entity/FrequentlyAskedQuestionSpec.php b/spec/Entity/FrequentlyAskedQuestionSpec.php index f4c576cad..ceee3b218 100755 --- a/spec/Entity/FrequentlyAskedQuestionSpec.php +++ b/spec/Entity/FrequentlyAskedQuestionSpec.php @@ -18,22 +18,22 @@ final class FrequentlyAskedQuestionSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(FrequentlyAskedQuestion::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_frequently_asked_question_interface(): void + public function it_implements_frequently_asked_question_interface(): void { $this->shouldHaveType(FrequentlyAskedQuestionInterface::class); } - function it_allows_access_via_properties(): void + public function it_allows_access_via_properties(): void { $this->setCode('delivery_charges_for_orders'); $this->getCode()->shouldReturn('delivery_charges_for_orders'); @@ -45,7 +45,7 @@ function it_allows_access_via_properties(): void $this->isEnabled()->shouldReturn(true); } - function it_toggles(): void + public function it_toggles(): void { $this->enable(); $this->isEnabled()->shouldReturn(true); @@ -54,7 +54,7 @@ function it_toggles(): void $this->isEnabled()->shouldReturn(false); } - function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void + public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void { $this->addChannel($firstChannel); $this->hasChannel($firstChannel)->shouldReturn(true); diff --git a/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php b/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php index 79ef2d07a..5f7ad21e4 100755 --- a/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php +++ b/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php @@ -18,23 +18,23 @@ final class FrequentlyAskedQuestionTranslationSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType(FrequentlyAskedQuestionTranslation::class); } - function it_is_a_resource() + public function it_is_a_resource() { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_frequently_asked_question_translation_interface() + public function it_implements_frequently_asked_question_translation_interface() { $this->shouldHaveType(FrequentlyAskedQuestionTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties() + public function it_allows_access_via_properties() { $this->setQuestion('What are the delivery charges for orders from the Online Shop?'); $this->getQuestion()->shouldReturn('What are the delivery charges for orders from the Online Shop?'); diff --git a/spec/Entity/MediaTranslationSpec.php b/spec/Entity/MediaTranslationSpec.php index d4657ef19..66f53fd4e 100755 --- a/spec/Entity/MediaTranslationSpec.php +++ b/spec/Entity/MediaTranslationSpec.php @@ -12,30 +12,29 @@ use BitBag\SyliusCmsPlugin\Entity\MediaTranslation; use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface; -use BitBag\SyliusCmsPlugin\Entity\PageImageInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslationInterface; final class MediaTranslationSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(MediaTranslation::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_media_translation_interface(): void + public function it_implements_media_translation_interface(): void { $this->shouldHaveType(MediaTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties(): void + public function it_allows_access_via_properties(): void { $this->setName('Video'); $this->getName()->shouldReturn('Video'); diff --git a/spec/Entity/PageSpec.php b/spec/Entity/PageSpec.php index afc543142..0618b8c9b 100755 --- a/spec/Entity/PageSpec.php +++ b/spec/Entity/PageSpec.php @@ -20,28 +20,28 @@ final class PageSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(Page::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_page_interface(): void + public function it_implements_page_interface(): void { $this->shouldHaveType(PageInterface::class); } - function it_allows_access_via_properties(): void + public function it_allows_access_via_properties(): void { $this->setCode('homepage'); $this->getCode()->shouldReturn('homepage'); } - function it_toggles(): void + public function it_toggles(): void { $this->enable(); $this->isEnabled()->shouldReturn(true); @@ -50,7 +50,7 @@ function it_toggles(): void $this->isEnabled()->shouldReturn(false); } - function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void + public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void { $this->addProduct($firstProduct); $this->hasProduct($firstProduct)->shouldReturn(true); @@ -62,7 +62,7 @@ function it_associates_products(ProductInterface $firstProduct, ProductInterface $this->hasProduct($firstProduct)->shouldReturn(false); } - function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void { $this->addSection($firstSection); $this->hasSection($firstSection)->shouldReturn(true); @@ -74,7 +74,7 @@ function it_associates_sections(SectionInterface $firstSection, SectionInterface $this->hasSection($firstSection)->shouldReturn(false); } - function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void + public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void { $this->addChannel($firstChannel); $this->hasChannel($firstChannel)->shouldReturn(true); @@ -86,7 +86,7 @@ function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $this->hasChannel($firstChannel)->shouldReturn(false); } - function it_is_timestampable(): void + public function it_is_timestampable(): void { $dateTime = new \DateTime(); diff --git a/spec/Entity/PageTranslationSpec.php b/spec/Entity/PageTranslationSpec.php index 3f59e16a1..75ecd391b 100755 --- a/spec/Entity/PageTranslationSpec.php +++ b/spec/Entity/PageTranslationSpec.php @@ -19,23 +19,23 @@ final class PageTranslationSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(PageTranslation::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_page_translation_interface(): void + public function it_implements_page_translation_interface(): void { $this->shouldHaveType(PageTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties(MediaInterface $pageImage): void + public function it_allows_access_via_properties(MediaInterface $pageImage): void { $this->setName('Homepage'); $this->getName()->shouldReturn('Homepage'); diff --git a/spec/Entity/SectionSpec.php b/spec/Entity/SectionSpec.php index 11a402cb7..99930c980 100755 --- a/spec/Entity/SectionSpec.php +++ b/spec/Entity/SectionSpec.php @@ -17,22 +17,22 @@ final class SectionSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(Section::class); } - function it_is_a_resource(): void + public function it_is_a_resource(): void { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_section_interface(): void + public function it_implements_section_interface(): void { $this->shouldHaveType(SectionInterface::class); } - function it_allows_access_via_properties(): void + public function it_allows_access_via_properties(): void { $this->setCode('blog'); $this->getCode()->shouldReturn('blog'); diff --git a/spec/Entity/SectionTranslationSpec.php b/spec/Entity/SectionTranslationSpec.php index 21b6fa13e..ea503732c 100755 --- a/spec/Entity/SectionTranslationSpec.php +++ b/spec/Entity/SectionTranslationSpec.php @@ -18,23 +18,23 @@ final class SectionTranslationSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType(SectionTranslation::class); } - function it_is_a_resource() + public function it_is_a_resource() { $this->shouldHaveType(ResourceInterface::class); } - function it_implements_frequently_asked_question_translation_interface() + public function it_implements_frequently_asked_question_translation_interface() { $this->shouldHaveType(SectionTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } - function it_allows_access_via_properties() + public function it_allows_access_via_properties() { $this->setName('Blog'); $this->getName()->shouldReturn('Blog'); diff --git a/spec/EventListener/MediaUploadListenerSpec.php b/spec/EventListener/MediaUploadListenerSpec.php index 88dbb242b..c2017ce8e 100755 --- a/spec/EventListener/MediaUploadListenerSpec.php +++ b/spec/EventListener/MediaUploadListenerSpec.php @@ -25,12 +25,12 @@ public function let(MediaProviderResolverInterface $mediaProviderResolver): void $this->beConstructedWith($mediaProviderResolver); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(MediaUploadListener::class); } - function it_does_not_upload_if_not_media_instance( + public function it_does_not_upload_if_not_media_instance( ResourceControllerEvent $event, MediaInterface $media, MediaProviderResolverInterface $mediaProviderResolver @@ -40,7 +40,7 @@ function it_does_not_upload_if_not_media_instance( $mediaProviderResolver->resolveProvider($media)->shouldNotBeCalled(); } - function it_uploads_media( + public function it_uploads_media( ResourceControllerEvent $event, MediaInterface $media, MediaProviderResolverInterface $mediaProviderResolver, diff --git a/spec/Exception/ImportFailedExceptionSpec.php b/spec/Exception/ImportFailedExceptionSpec.php index 2046148b7..15597534d 100755 --- a/spec/Exception/ImportFailedExceptionSpec.php +++ b/spec/Exception/ImportFailedExceptionSpec.php @@ -15,22 +15,22 @@ final class ImportFailedExceptionSpec extends ObjectBehavior { - function let(): void + public function let(): void { $this->beConstructedWith('not blank', 1); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ImportFailedException::class); } - function it_is_an_exception(): void + public function it_is_an_exception(): void { $this->shouldHaveType(\Exception::class); } - function it_has_custom_message(): void + public function it_has_custom_message(): void { $this->getMessage()->shouldReturn('Import failed at index 1. Exception message: not blank'); } diff --git a/spec/Importer/BlockImporterSpec.php b/spec/Importer/BlockImporterSpec.php new file mode 100644 index 000000000..8801d74c7 --- /dev/null +++ b/spec/Importer/BlockImporterSpec.php @@ -0,0 +1,90 @@ +beConstructedWith( + $blockResourceResolver, + $localeContext, + $importerSectionsResolver, + $importerChannelsResolver, + $importerProductsResolver, + $validator, + $blockRepository + ); + } + + public function it_is_initializable() + { + $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\BlockImporter::class); + $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\BlockImporterInterface::class); + } + + public function it_imports_block( + ResourceResolverInterface $blockResourceResolver, + LocaleContextInterface $localeContext, + ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + BlockRepositoryInterface $blockRepository, + BlockInterface $block + ) { + $row = ['name_pl' => 'name', 'content_pl' => 'content', 'link_pl' => 'link', 'code' => 'block_code']; + + $blockResourceResolver->getResource('block_code')->willReturn($block); + + $localeContext->getLocaleCode()->willReturn('en_US'); + + $block->setCode('block_code')->shouldBeCalled(); + $block->setFallbackLocale('en_US')->shouldBeCalled(); + $block->setCurrentLocale('pl')->shouldBeCalled(); + $block->setName('name')->shouldBeCalled(); + $block->setLink('link')->shouldBeCalled(); + $block->setContent('content')->shouldBeCalled(); + + $importerSectionsResolver->resolve($block, null)->shouldBeCalled(); + $importerChannelsResolver->resolve($block, null)->shouldBeCalled(); + $importerProductsResolver->resolve($block, null)->shouldBeCalled(); + + $validator->validate($block, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + + $blockRepository->add($block)->shouldBeCalled(); + + $this->import($row); + } + + public function it_gets_resource_code() + { + $this->getResourceCode()->shouldReturn('block'); + } +} diff --git a/spec/Importer/MediaImporterSpec.php b/spec/Importer/MediaImporterSpec.php new file mode 100644 index 000000000..2b8171d85 --- /dev/null +++ b/spec/Importer/MediaImporterSpec.php @@ -0,0 +1,85 @@ +beConstructedWith( + $mediaResourceResolver, + $localeContext, + $importerSectionsResolver, + $importerProductsResolver, + $validator, + $mediaRepository, + ); + } + + public function it_is_initializable() + { + $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\MediaImporter::class); + $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\MediaImporterInterface::class); + } + + public function it_imports_media( + ResourceResolverInterface $mediaResourceResolver, + LocaleContextInterface $localeContext, + ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + MediaRepositoryInterface $mediaRepository, + MediaInterface $media + ) { + $row = ['name_pl' => 'name', 'content_pl' => 'content', 'alt_pl' => 'alt', 'code' => 'media_code']; + + $mediaResourceResolver->getResource('media_code')->willReturn($media); + $localeContext->getLocaleCode()->willReturn('en_US'); + + $media->setCode('media_code')->shouldBeCalled(); + $media->setType(null)->shouldBeCalled(); + $media->setFallbackLocale('en_US')->shouldBeCalled(); + $media->setCurrentLocale('pl')->shouldBeCalled(); + $media->setName('name')->shouldBeCalled(); + $media->setContent('content')->shouldBeCalled(); + $media->setAlt('alt')->shouldBeCalled(); + + $importerSectionsResolver->resolve($media, null)->shouldBeCalled(); + $importerProductsResolver->resolve($media, null)->shouldBeCalled(); + + $validator->validate($media, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + + $mediaRepository->add($media)->shouldBeCalled(); + + $this->import($row); + } + + public function it_gets_resource_code() + { + $this->getResourceCode()->shouldReturn('media'); + } +} diff --git a/spec/Importer/PageImporterSpec.php b/spec/Importer/PageImporterSpec.php new file mode 100644 index 000000000..2a014971d --- /dev/null +++ b/spec/Importer/PageImporterSpec.php @@ -0,0 +1,122 @@ +beConstructedWith( + $pageResourceResolver, + $localeContext, + $imageDownloader, + $mediaFactory, + $mediaProviderResolver, + $importerSectionsResolver, + $importerChannelsResolver, + $importerProductsResolver, + $validator, + $entityManager, + ); + } + + public function it_is_initializable() + { + $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\PageImporter::class); + $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\PageImporterInterface::class); + } + + public function it_imports_page_no_url( + ResourceResolverInterface $pageResourceResolver, + LocaleContextInterface $localeContext, + ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + EntityManagerInterface $entityManager, + PageInterface $page, + ) { + $row = [ + 'code' => 'page_code', + 'slug_pl' => 'slug', + 'name_pl' => 'name', + 'image_pl' => null, + 'imagecode_pl' => 'imagecode', + 'metakeywords_pl' => 'metakeywords', + 'metadescription_pl' => 'metadescription', + 'content_pl' => 'content', + 'breadcrumb_pl' => 'breadcrumb', + 'namewhenlinked_pl' => 'namewhenlinked', + 'descriptionwhenlinked_pl' => 'descriptionwhenlinked', + 'sections' => 'sections', + 'channels' => 'channels', + 'products' => 'products', + ]; + + $pageResourceResolver->getResource('page_code')->willReturn($page); + + $localeContext->getLocaleCode()->willReturn('en_US'); + + $page->setCode('page_code')->shouldBeCalled(); + $page->setFallbackLocale('en_US')->shouldBeCalled(); + + $page->setCurrentLocale('pl')->shouldBeCalled(); + + $page->setSlug('slug')->shouldBeCalled(); + $page->setName('name')->shouldBeCalled(); + $page->setMetaKeywords('metakeywords')->shouldBeCalled(); + $page->setMetaDescription('metadescription')->shouldBeCalled(); + $page->setContent('content')->shouldBeCalled(); + $page->setBreadcrumb('breadcrumb')->shouldBeCalled(); + $page->setNameWhenLinked('namewhenlinked')->shouldBeCalled(); + $page->setDescriptionWhenLinked('descriptionwhenlinked')->shouldBeCalled(); + + $importerSectionsResolver->resolve($page, 'sections')->shouldBeCalled(); + $importerChannelsResolver->resolve($page, 'channels')->shouldBeCalled(); + $importerProductsResolver->resolve($page, 'products')->shouldBeCalled(); + + $validator->validate($page, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + + $entityManager->persist($page)->shouldBeCalled(); + $entityManager->flush()->shouldBeCalled(); + + $this->import($row); + } + + public function it_gets_resource_code() + { + $this->getResourceCode()->shouldReturn('page'); + } +} diff --git a/spec/MediaProvider/FilenameHelperSpec.php b/spec/MediaProvider/FilenameHelperSpec.php new file mode 100644 index 000000000..dd9312bbe --- /dev/null +++ b/spec/MediaProvider/FilenameHelperSpec.php @@ -0,0 +1,48 @@ +shouldHaveType(FilenameHelper::class); + } + + public function it_removes_slashes_from_the_string() + { + $string = 'path/to/file'; + $expectedResult = 'pathtofile'; + + $this->removeSlashes($string)->shouldBe($expectedResult); + } + + public function it_replaces_slashes_with_the_provided_string() + { + $string = 'path/to/file'; + $replaceWith = '-'; + $expectedResult = 'path-to-file'; + + $this->removeSlashes($string, $replaceWith)->shouldBe($expectedResult); + } + + public function it_does_not_modify_the_string_if_no_slashes_are_present() + { + $string = 'filename'; + $expectedResult = 'filename'; + + $this->removeSlashes($string)->shouldBe($expectedResult); + } +} diff --git a/spec/MediaProvider/GenericProviderSpec.php b/spec/MediaProvider/GenericProviderSpec.php index dc0714608..098d51d65 100644 --- a/spec/MediaProvider/GenericProviderSpec.php +++ b/spec/MediaProvider/GenericProviderSpec.php @@ -19,19 +19,19 @@ final class GenericProviderSpec extends ObjectBehavior { - function let( + public function let( MediaUploaderInterface $uploader, Environment $twigEngine ) { $this->beConstructedWith($uploader, $twigEngine, '@Template', '/media/'); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(GenericProvider::class); } - function it_implements_provider_interface(): void + public function it_implements_provider_interface(): void { $this->shouldHaveType(ProviderInterface::class); } diff --git a/spec/Menu/ContentManagementMenuBuilderSpec.php b/spec/Menu/ContentManagementMenuBuilderSpec.php index 83f401dca..d5ab533dd 100755 --- a/spec/Menu/ContentManagementMenuBuilderSpec.php +++ b/spec/Menu/ContentManagementMenuBuilderSpec.php @@ -17,12 +17,12 @@ final class ContentManagementMenuBuilderSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ContentManagementMenuBuilder::class); } - function it_build_menu( + public function it_build_menu( MenuBuilderEvent $menuBuilderEvent, ItemInterface $menu, ItemInterface $cmsRootMenuItem diff --git a/spec/Processor/ImportProcessorSpec.php b/spec/Processor/ImportProcessorSpec.php new file mode 100644 index 000000000..b1129d087 --- /dev/null +++ b/spec/Processor/ImportProcessorSpec.php @@ -0,0 +1,83 @@ +beConstructedWith($importerChain, $reader, $entityManager); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImportProcessor::class); + } + + public function it_processes_import_data( + ImporterChainInterface $importerChain, + ReaderInterface $reader, + EntityManagerInterface $entityManager, + ImporterInterface $importer + ) { + $resourceCode = 'some_resource'; + $filePath = 'path/to/file.csv'; + $data = [ + ['col1' => 'value1', 'col2' => 'value2'], + ['col1' => 'value3', 'col2' => 'value4'], + ]; + + $iterator = new \ArrayIterator($data); + + $importerChain->getImporterForResource($resourceCode)->willReturn($importer); + $reader->read($filePath)->willReturn($iterator); + + $importer->import($data[0])->shouldBeCalled(); + $importer->import($data[1])->shouldBeCalled(); + + $entityManager->clear()->shouldBeCalled(); + $importer->cleanup()->shouldBeCalled(); + + $this->process($resourceCode, $filePath); + } + + public function it_throws_exception_when_import_fails( + ImporterChainInterface $importerChain, + ReaderInterface $reader, + EntityManagerInterface $entityManager, + ImporterInterface $importer + ) { + $resourceCode = 'some_resource'; + $filePath = 'path/to/file.csv'; + $data = [['col1' => 'value1', 'col2' => 'value2']]; + + $iterator = new \ArrayIterator($data); + $importerChain->getImporterForResource($resourceCode)->willReturn($importer); + + $reader->read($filePath)->willReturn($iterator); + + $importer->import($data[0])->willThrow(new \Exception('Import error')); + + $this->shouldThrow(ImportFailedException::class)->during('process', [$resourceCode, $filePath]); + } +} diff --git a/spec/Resolver/BlockResourceResolverSpec.php b/spec/Resolver/BlockResourceResolverSpec.php index 489f5a70f..1f9af7155 100755 --- a/spec/Resolver/BlockResourceResolverSpec.php +++ b/spec/Resolver/BlockResourceResolverSpec.php @@ -21,22 +21,25 @@ final class BlockResourceResolverSpec extends ObjectBehavior { - function let(BlockRepositoryInterface $blockRepository, LoggerInterface $logger, ChannelContextInterface $channelContext) - { + public function let( + BlockRepositoryInterface $blockRepository, + LoggerInterface $logger, + ChannelContextInterface $channelContext + ) { $this->beConstructedWith($blockRepository, $logger, $channelContext); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(BlockResourceResolver::class); } - function it_implements_block_resource_resolver_interface(): void + public function it_implements_block_resource_resolver_interface(): void { $this->shouldHaveType(BlockResourceResolverInterface::class); } - function it_logs_warning_if_block_was_not_found( + public function it_logs_warning_if_block_was_not_found( BlockRepositoryInterface $blockRepository, LoggerInterface $logger, ChannelContextInterface $channelContext, @@ -57,7 +60,7 @@ function it_logs_warning_if_block_was_not_found( $this->findOrLog('homepage_banner'); } - function it_returns_block_if_found_in_database( + public function it_returns_block_if_found_in_database( BlockRepositoryInterface $blockRepository, BlockInterface $block, ChannelContextInterface $channelContext, diff --git a/spec/Resolver/ImporterChannelsResolverSpec.php b/spec/Resolver/ImporterChannelsResolverSpec.php new file mode 100644 index 000000000..c4ac903af --- /dev/null +++ b/spec/Resolver/ImporterChannelsResolverSpec.php @@ -0,0 +1,53 @@ +beConstructedWith($channelsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterChannelsResolver::class); + } + + public function it_resolves_channels_for_channels_aware( + ChannelsAssignerInterface $channelsAssigner, + ChannelsAwareInterface $channelsAware + ) { + $channelsRow = 'channel1, channel2, channel3'; + $channelsCodes = ['channel1', 'channel2', 'channel3']; + + $channelsAssigner->assign($channelsAware, $channelsCodes)->shouldBeCalled(); + + $this->resolve($channelsAware, $channelsRow); + } + + public function it_skips_resolution_when_channels_row_is_null( + ChannelsAssignerInterface $channelsAssigner, + ChannelsAwareInterface $channelsAware + ) { + $channelsRow = null; + + $channelsAssigner->assign($channelsAware, Argument::any())->shouldNotBeCalled(); + + $this->resolve($channelsAware, $channelsRow); + } +} diff --git a/spec/Resolver/ImporterProductsResolverSpec.php b/spec/Resolver/ImporterProductsResolverSpec.php new file mode 100644 index 000000000..3b3bd5b96 --- /dev/null +++ b/spec/Resolver/ImporterProductsResolverSpec.php @@ -0,0 +1,53 @@ +beConstructedWith($productsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterProductsResolver::class); + } + + public function it_resolves_products_for_products_aware( + ProductsAssignerInterface $productsAssigner, + ProductsAwareInterface $productsAware + ) { + $productsRow = 'product1, product2, product3'; + $productsCodes = ['product1', 'product2', 'product3']; + + $productsAssigner->assign($productsAware, $productsCodes)->shouldBeCalled(); + + $this->resolve($productsAware, $productsRow); + } + + public function it_skips_resolution_when_products_row_is_null( + ProductsAssignerInterface $productsAssigner, + ProductsAwareInterface $productsAware + ) { + $productsRow = null; + + $productsAssigner->assign($productsAware, Argument::any())->shouldNotBeCalled(); + + $this->resolve($productsAware, $productsRow); + } +} diff --git a/spec/Resolver/ImporterSectionsResolverSpec.php b/spec/Resolver/ImporterSectionsResolverSpec.php new file mode 100644 index 000000000..83cc8dd11 --- /dev/null +++ b/spec/Resolver/ImporterSectionsResolverSpec.php @@ -0,0 +1,53 @@ +beConstructedWith($sectionsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterSectionsResolver::class); + } + + public function it_resolves_sections_for_sectionable_entity( + SectionsAssignerInterface $sectionsAssigner, + SectionableInterface $sectionable + ) { + $sectionsRow = 'section1, section2, section3'; + $sectionCodes = ['section1', 'section2', 'section3']; + + $sectionsAssigner->assign($sectionable, $sectionCodes)->shouldBeCalled(); + + $this->resolve($sectionable, $sectionsRow); + } + + public function it_skips_resolution_when_sections_row_is_null( + SectionsAssignerInterface $sectionsAssigner, + SectionableInterface $sectionable + ) { + $sectionsRow = null; + + $sectionsAssigner->assign($sectionable, Argument::any())->shouldNotBeCalled(); + + $this->resolve($sectionable, $sectionsRow); + } +} diff --git a/spec/Resolver/MediaProviderResolverSpec.php b/spec/Resolver/MediaProviderResolverSpec.php new file mode 100644 index 000000000..5010793c9 --- /dev/null +++ b/spec/Resolver/MediaProviderResolverSpec.php @@ -0,0 +1,54 @@ +beConstructedWith($providerRegistry); + } + + public function it_is_initializable() + { + $this->shouldHaveType(MediaProviderResolver::class); + $this->shouldImplement(MediaProviderResolverInterface::class); + } + + public function it_resolves_provider_for_media( + ServiceRegistryInterface $providerRegistry, + MediaInterface $media, + ProviderInterface $provider + ) { + $mediaType = 'image'; + $media->getType()->willReturn($mediaType); + + $providerRegistry->get($mediaType)->willReturn($provider); + + $this->resolveProvider($media)->shouldReturn($provider); + } + + public function it_throws_exception_when_media_type_is_null( + MediaInterface $media + ) { + $media->getType()->willReturn(null); + + $this->shouldThrow(InvalidArgumentException::class)->during('resolveProvider', [$media]); + } +} diff --git a/spec/Resolver/MediaResourceResolverSpec.php b/spec/Resolver/MediaResourceResolverSpec.php new file mode 100644 index 000000000..a3fb1a139 --- /dev/null +++ b/spec/Resolver/MediaResourceResolverSpec.php @@ -0,0 +1,85 @@ +beConstructedWith($mediaRepository, $localeContext, $channelContext, $logger); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(MediaResourceResolver::class); + } + + public function it_implements_media_resource_resolver_interface(): void + { + $this->shouldHaveType(MediaResourceResolverInterface::class); + } + + public function it_returns_media_when_found( + MediaRepositoryInterface $mediaRepository, + LocaleContextInterface $localeContext, + ChannelContextInterface $channelContext, + MediaInterface $media, + ChannelInterface $channel, + ) { + $code = 'media_code'; + $localeCode = 'en_US'; + $channelCode = 'ecommerce'; + + $channelContext->getChannel()->willReturn($channel); + $channel->getCode()->willReturn($channelCode); + $localeContext->getLocaleCode()->willReturn($localeCode); + + $mediaRepository->findOneEnabledByCode($code, $localeCode, $channelCode)->willReturn($media); + + $this->findOrLog($code)->shouldReturn($media); + } + + public function it_logs_warning_and_returns_null_when_media_not_found( + MediaRepositoryInterface $mediaRepository, + LocaleContextInterface $localeContext, + ChannelContextInterface $channelContext, + LoggerInterface $logger, + ChannelInterface $channel, + ) { + $code = 'non_existing_code'; + $localeCode = 'en_US'; + $channelCode = 'ecommerce'; + + $channelContext->getChannel()->willReturn($channel); + $channel->getCode()->willReturn($channelCode); + $localeContext->getLocaleCode()->willReturn($localeCode); + + $mediaRepository->findOneEnabledByCode($code, $localeCode, $channelCode)->willReturn(null); + + $logger->warning(sprintf('Media with "%s" code was not found in the database.', $code))->shouldBeCalled(); + + $this->findOrLog($code)->shouldReturn(null); + } +} diff --git a/spec/Resolver/PageResourceResolverSpec.php b/spec/Resolver/PageResourceResolverSpec.php index 7a8b6af4e..903e409ef 100755 --- a/spec/Resolver/PageResourceResolverSpec.php +++ b/spec/Resolver/PageResourceResolverSpec.php @@ -20,22 +20,25 @@ final class PageResourceResolverSpec extends ObjectBehavior { - function let(PageRepositoryInterface $pageRepository, LocaleContextInterface $localeContext, LoggerInterface $logger) - { + public function let( + PageRepositoryInterface $pageRepository, + LocaleContextInterface $localeContext, + LoggerInterface $logger + ) { $this->beConstructedWith($pageRepository, $localeContext, $logger); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(PageResourceResolver::class); } - function it_implements_page_resource_resolver_interface(): void + public function it_implements_page_resource_resolver_interface(): void { $this->shouldHaveType(PageResourceResolverInterface::class); } - function it_logs_warning_if_page_was_not_found( + public function it_logs_warning_if_page_was_not_found( PageRepositoryInterface $pageRepository, LocaleContextInterface $localeContext, LoggerInterface $logger @@ -54,7 +57,7 @@ function it_logs_warning_if_page_was_not_found( $this->findOrLog('homepage_banner'); } - function it_returns_page_if_found_in_database( + public function it_returns_page_if_found_in_database( PageRepositoryInterface $pageRepository, LocaleContextInterface $localeContext, PageInterface $page diff --git a/spec/Resolver/ResourceResolverSpec.php b/spec/Resolver/ResourceResolverSpec.php new file mode 100644 index 000000000..74817d9bf --- /dev/null +++ b/spec/Resolver/ResourceResolverSpec.php @@ -0,0 +1,69 @@ +beConstructedWith($repository, $factory, 'unique_column'); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ResourceResolver::class); + } + + public function it_returns_existing_resource_from_repository( + RepositoryInterface $repository, + ResourceInterface $resource + ) { + $identifier = 'resource_identifier'; + + $repository->findOneBy(['unique_column' => $identifier])->willReturn($resource); + + $this->getResource($identifier)->shouldReturn($resource); + } + + public function it_creates_new_resource_using_factory( + RepositoryInterface $repository, + FactoryInterface $factory, + ResourceInterface $newResource + ) { + $identifier = 'resource_identifier'; + $factoryMethod = 'createNew'; + + $repository->findOneBy(['unique_column' => $identifier])->willReturn(null); + $factory->createNew()->willReturn($newResource); + + $this->getResource($identifier, $factoryMethod)->shouldReturn($newResource); + } + + public function it_throws_exception_when_factory_method_not_callable( + RepositoryInterface $repository, + FactoryInterface $factory + ) { + $identifier = 'resource_identifier'; + $factoryMethod = 'nonExistingMethod'; + + $repository->findOneBy(['unique_column' => $identifier])->willReturn(null); + + $this->shouldThrow(\BadFunctionCallException::class)->during('getResource', [$identifier, $factoryMethod]); + } +} diff --git a/spec/Sorter/SectionsSorterSpec.php b/spec/Sorter/SectionsSorterSpec.php index e73e40124..3b20091dd 100644 --- a/spec/Sorter/SectionsSorterSpec.php +++ b/spec/Sorter/SectionsSorterSpec.php @@ -21,31 +21,31 @@ final class SectionsSorterSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(SectionsSorter::class); } - function it_implements_sections_sorter_interface(): void + public function it_implements_sections_sorter_interface(): void { $this->shouldHaveType(SectionsSorterInterface::class); } - function it_sorts_sections_with_one_element( + public function it_sorts_sections_with_one_element( PageInterface $page, SectionInterface $section ): void { - $section->getCode()->willReturn("SECTION_CODE"); + $section->getCode()->willReturn('SECTION_CODE'); $page->getSections()->willReturn(new ArrayCollection([$section->getWrappedObject()])); $this->sortBySections([$page])->shouldReturn( [ - "SECTION_CODE" => ['section' => $section, 0 => $page] + 'SECTION_CODE' => ['section' => $section, 0 => $page], ] ); } - function it_sorts_sections_with_more_elements( + public function it_sorts_sections_with_more_elements( PageInterface $page1, PageInterface $page2, PageInterface $page3, @@ -53,9 +53,9 @@ function it_sorts_sections_with_more_elements( SectionInterface $section2, SectionInterface $section3 ): void { - $section1->getCode()->willReturn("SECTION_1_CODE"); - $section2->getCode()->willReturn("SECTION_2_CODE"); - $section3->getCode()->willReturn("SECTION_3_CODE"); + $section1->getCode()->willReturn('SECTION_1_CODE'); + $section2->getCode()->willReturn('SECTION_2_CODE'); + $section3->getCode()->willReturn('SECTION_3_CODE'); $page1->getSections()->willReturn(new ArrayCollection( [$section1->getWrappedObject(), $section3->getWrappedObject()] @@ -67,29 +67,29 @@ function it_sorts_sections_with_more_elements( $this->sortBySections([$page1, $page2, $page3])->shouldReturn( [ - "SECTION_1_CODE" => ['section' => $section1, 0 => $page1, 1 => $page3], - "SECTION_3_CODE" => ['section' => $section3, 0 => $page1, 1 => $page2], - "SECTION_2_CODE" => ['section' => $section2, 0 => $page3], + 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1, 1 => $page3], + 'SECTION_3_CODE' => ['section' => $section3, 0 => $page1, 1 => $page2], + 'SECTION_2_CODE' => ['section' => $section2, 0 => $page3], ] ); } - function it_sorts_sections_with_less_elements( + public function it_sorts_sections_with_less_elements( PageInterface $page1, PageInterface $page2, SectionInterface $section1, SectionInterface $section2 ): void { - $section1->getCode()->willReturn("SECTION_1_CODE"); - $section2->getCode()->willReturn("SECTION_2_CODE"); + $section1->getCode()->willReturn('SECTION_1_CODE'); + $section2->getCode()->willReturn('SECTION_2_CODE'); $page1->getSections()->willReturn(new ArrayCollection([$section1->getWrappedObject()])); $page2->getSections()->willReturn(new ArrayCollection([$section2->getWrappedObject()])); $this->sortBySections([$page1, $page2])->shouldReturn( [ - "SECTION_1_CODE" => ['section' => $section1, 0 => $page1], - "SECTION_2_CODE" => ['section' => $section2, 0 => $page2], + 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1], + 'SECTION_2_CODE' => ['section' => $section2, 0 => $page2], ] ); } diff --git a/spec/Twig/Extension/RenderBlockExtensionSpec.php b/spec/Twig/Extension/RenderBlockExtensionSpec.php index c17d04147..a2d6c2985 100755 --- a/spec/Twig/Extension/RenderBlockExtensionSpec.php +++ b/spec/Twig/Extension/RenderBlockExtensionSpec.php @@ -18,23 +18,23 @@ final class RenderBlockExtensionSpec extends ObjectBehavior { - function let( + public function let( RenderBlockRuntimeInterface $blockRuntime ): void { $this->beConstructedWith($blockRuntime); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderBlockExtension::class); } - function it_extends_abstract_extension(): void + public function it_extends_abstract_extension(): void { $this->shouldHaveType(AbstractExtension::class); } - function it_returns_functions(): void + public function it_returns_functions(): void { $functions = $this->getFunctions(); diff --git a/spec/Twig/Extension/RenderContentExtensionSpec.php b/spec/Twig/Extension/RenderContentExtensionSpec.php index 2cd2d582f..52e8c7f2c 100644 --- a/spec/Twig/Extension/RenderContentExtensionSpec.php +++ b/spec/Twig/Extension/RenderContentExtensionSpec.php @@ -17,17 +17,17 @@ final class RenderContentExtensionSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderContentExtension::class); } - function it_extends_abstract_extension(): void + public function it_extends_abstract_extension(): void { $this->shouldHaveType(AbstractExtension::class); } - function it_returns_functions(): void + public function it_returns_functions(): void { $functions = $this->getFunctions(); diff --git a/spec/Twig/Extension/RenderLinkExtensionSpec.php b/spec/Twig/Extension/RenderLinkExtensionSpec.php index f87f97f44..cf29332b4 100644 --- a/spec/Twig/Extension/RenderLinkExtensionSpec.php +++ b/spec/Twig/Extension/RenderLinkExtensionSpec.php @@ -19,17 +19,17 @@ final class RenderLinkExtensionSpec extends ObjectBehavior { - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderLinkExtension::class); } - function it_extends_abstract_extension(): void + public function it_extends_abstract_extension(): void { $this->shouldHaveType(AbstractExtension::class); } - function it_returns_functions(): void + public function it_returns_functions(): void { $functions = $this->getFunctions(); diff --git a/spec/Twig/Extension/RenderMediaExtensionSpec.php b/spec/Twig/Extension/RenderMediaExtensionSpec.php index 89a3e3223..7fd5959cd 100755 --- a/spec/Twig/Extension/RenderMediaExtensionSpec.php +++ b/spec/Twig/Extension/RenderMediaExtensionSpec.php @@ -18,23 +18,23 @@ final class RenderMediaExtensionSpec extends ObjectBehavior { - function let( + public function let( RenderMediaRuntimeInterface $mediaRuntime ) { $this->beConstructedWith($mediaRuntime); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderMediaExtension::class); } - function it_extends_abstract_extension(): void + public function it_extends_abstract_extension(): void { $this->shouldHaveType(AbstractExtension::class); } - function it_returns_functions(): void + public function it_returns_functions(): void { $functions = $this->getFunctions(); diff --git a/spec/Twig/Extension/RenderProductPagesExtensionSpec.php b/spec/Twig/Extension/RenderProductPagesExtensionSpec.php index 9ba1c7caf..04c66790b 100755 --- a/spec/Twig/Extension/RenderProductPagesExtensionSpec.php +++ b/spec/Twig/Extension/RenderProductPagesExtensionSpec.php @@ -17,23 +17,23 @@ final class RenderProductPagesExtensionSpec extends ObjectBehavior { - function let( + public function let( RenderProductPagesRuntimeInterface $productPagesRuntime ): void { $this->beConstructedWith($productPagesRuntime); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderProductPagesExtension::class); } - function it_extends_abstract_extension(): void + public function it_extends_abstract_extension(): void { $this->shouldHaveType(AbstractExtension::class); } - function it_returns_functions(): void + public function it_returns_functions(): void { $functions = $this->getFunctions(); diff --git a/spec/Twig/Parser/ContentParserSpec.php b/spec/Twig/Parser/ContentParserSpec.php index c14fcb00b..797087c76 100644 --- a/spec/Twig/Parser/ContentParserSpec.php +++ b/spec/Twig/Parser/ContentParserSpec.php @@ -1,5 +1,7 @@ beConstructedWith($twigEnvironment, ['bitbag_cms_render_block']); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(ContentParser::class); } - function it_implements_content_parser_interface(): void + public function it_implements_content_parser_interface(): void { $this->shouldHaveType(ContentParserInterface::class); } - function it_parses_string_function( + public function it_parses_string_function( Environment $twigEnvironment, TwigFunction $renderBlockFunction, RenderBlockRuntimeInterface $renderBlockRuntime - ): void - { + ): void { $twigEnvironment->getFunctions()->willReturn([ 'bitbag_cms_render_block' => $renderBlockFunction, ]); @@ -44,12 +45,11 @@ function it_parses_string_function( $this->parse($input); } - function it_parses_string_functions( + public function it_parses_string_functions( Environment $twigEnvironment, TwigFunction $renderBlockFunction, RenderBlockRuntimeInterface $renderBlockRuntime - ): void - { + ): void { $twigEnvironment->getFunctions()->willReturn([ 'bitbag_cms_render_block' => $renderBlockFunction, ]); diff --git a/spec/Twig/Runtime/RenderBlockRuntimeSpec.php b/spec/Twig/Runtime/RenderBlockRuntimeSpec.php index 547df8f18..fca4ad8a5 100644 --- a/spec/Twig/Runtime/RenderBlockRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderBlockRuntimeSpec.php @@ -13,7 +13,6 @@ namespace spec\BitBag\SyliusCmsPlugin\Twig\Runtime; use BitBag\SyliusCmsPlugin\Entity\BlockInterface; -use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface; use BitBag\SyliusCmsPlugin\Resolver\BlockResourceResolverInterface; use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderBlockRuntime; use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderBlockRuntimeInterface; @@ -22,25 +21,24 @@ final class RenderBlockRuntimeSpec extends ObjectBehavior { - function let( - BlockRepositoryInterface $blockRepository, + public function let( BlockResourceResolverInterface $blockResourceResolver, Environment $templatingEngine ): void { - $this->beConstructedWith($blockRepository, $blockResourceResolver, $templatingEngine); + $this->beConstructedWith($blockResourceResolver, $templatingEngine); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderBlockRuntime::class); } - function it_implements_render_block_runtime_interface(): void + public function it_implements_render_block_runtime_interface(): void { $this->shouldHaveType(RenderBlockRuntimeInterface::class); } - function it_renders_block( + public function it_renders_block( BlockResourceResolverInterface $blockResourceResolver, BlockInterface $block, Environment $templatingEngine @@ -51,7 +49,7 @@ function it_renders_block( $this->renderBlock('bitbag'); } - function it_renders_block_with_template( + public function it_renders_block_with_template( BlockResourceResolverInterface $blockResourceResolver, BlockInterface $block, Environment $templatingEngine diff --git a/spec/Twig/Runtime/RenderContentRuntimeSpec.php b/spec/Twig/Runtime/RenderContentRuntimeSpec.php index 2088d8219..300f3d3e5 100644 --- a/spec/Twig/Runtime/RenderContentRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderContentRuntimeSpec.php @@ -20,23 +20,23 @@ final class RenderContentRuntimeSpec extends ObjectBehavior { - function let( + public function let( ContentParserInterface $contentParser ): void { $this->beConstructedWith($contentParser); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderContentRuntime::class); } - function it_implements_render_content_runtime_interface(): void + public function it_implements_render_content_runtime_interface(): void { $this->shouldHaveType(RenderContentRuntimeInterface::class); } - function it_renders_content( + public function it_renders_content( ContentParserInterface $contentParser, ContentableInterface $contentableResource ): void { diff --git a/spec/Twig/Runtime/RenderLinkRuntimeSpec.php b/spec/Twig/Runtime/RenderLinkRuntimeSpec.php index d4e5744cb..0440b8cfb 100644 --- a/spec/Twig/Runtime/RenderLinkRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderLinkRuntimeSpec.php @@ -24,71 +24,71 @@ final class RenderLinkRuntimeSpec extends ObjectBehavior { - function let( + public function let( LocaleContextInterface $localeContext, PageRepositoryInterface $pageRepository, RouterInterface $router ): void { - $this->beConstructedWith($localeContext, $pageRepository, $router, "defaultTemplate"); + $this->beConstructedWith($localeContext, $pageRepository, $router, 'defaultTemplate'); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderLinkRuntime::class); } - function it_implements_render_link_runtime_interface(): void + public function it_implements_render_link_runtime_interface(): void { $this->shouldHaveType(RenderLinkRuntimeInterface::class); } - function it_renders_link_for_code( + public function it_renders_link_for_code( Environment $environment, PageInterface $page, PageRepositoryInterface $pageRepository, LocaleContextInterface $localeContext ): void { $options = []; - $code = "CODE"; + $code = 'CODE'; $template = null; - $localeCode = "en_US"; + $localeCode = 'en_US'; $localeContext->getLocaleCode()->willReturn($localeCode); $pageRepository->findOneEnabledByCode($code, $localeCode)->willReturn($page); - $environment->render($template ?? "defaultTemplate", [ + $environment->render($template ?? 'defaultTemplate', [ 'page' => $page, 'options' => $options, - ])->willReturn("link"); + ])->willReturn('link'); - $this->renderLinkForCode($environment, $code, $options, $template)->shouldReturn("link"); + $this->renderLinkForCode($environment, $code, $options, $template)->shouldReturn('link'); } - function it_gets_link_for_code( + public function it_gets_link_for_code( RouterInterface $router, LocaleContextInterface $localeContext, PageRepositoryInterface $pageRepository, PageInterface $page ): void { - $code = "CODE"; - $localeCode = "en_US"; - $slug = "SLUG"; + $code = 'CODE'; + $localeCode = 'en_US'; + $slug = 'SLUG'; $options = []; $localeContext->getLocaleCode()->willReturn($localeCode); $pageRepository->findOneEnabledByCode($code, $localeCode)->willReturn($page); $page->getSlug()->willReturn($slug); - $router->generate('bitbag_sylius_cms_plugin_shop_page_show', ['slug' => $slug])->willReturn("link"); + $router->generate('bitbag_sylius_cms_plugin_shop_page_show', ['slug' => $slug])->willReturn('link'); - $this->getLinkForCode($code, $options)->shouldReturn("link"); + $this->getLinkForCode($code, $options)->shouldReturn('link'); } - function it_returns_not_found_message_when_getting_link_for_code( + public function it_returns_not_found_message_when_getting_link_for_code( LocaleContextInterface $localeContext ): void { - $localeContext->getLocaleCode()->willReturn("en_US"); + $localeContext->getLocaleCode()->willReturn('en_US'); - $this->shouldThrow(NotFoundHttpException::class)->during('getLinkForCode', ["CODE"]); + $this->shouldThrow(NotFoundHttpException::class)->during('getLinkForCode', ['CODE']); } } diff --git a/spec/Twig/Runtime/RenderMediaRuntimeSpec.php b/spec/Twig/Runtime/RenderMediaRuntimeSpec.php index ad572fe9a..f699e23e1 100644 --- a/spec/Twig/Runtime/RenderMediaRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderMediaRuntimeSpec.php @@ -22,24 +22,24 @@ final class RenderMediaRuntimeSpec extends ObjectBehavior { - function let( + public function let( MediaProviderResolverInterface $mediaProviderResolver, MediaResourceResolverInterface $mediaResourceResolver ): void { $this->beConstructedWith($mediaProviderResolver, $mediaResourceResolver); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderMediaRuntime::class); } - function it_implements_render_media_runtime_interface(): void + public function it_implements_render_media_runtime_interface(): void { $this->shouldHaveType(RenderMediaRuntimeInterface::class); } - function it_renders_media( + public function it_renders_media( MediaResourceResolverInterface $mediaResourceResolver, MediaProviderResolverInterface $mediaProviderResolver, ProviderInterface $provider, diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php index ecd1b9ed0..1406b14a2 100644 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php @@ -27,7 +27,7 @@ final class RenderProductPagesRuntimeSpec extends ObjectBehavior { - function let( + public function let( PageRepositoryInterface $pageRepository, ChannelContextInterface $channelContext, Environment $templatingEngine, @@ -36,17 +36,17 @@ function let( $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $sectionsSorter); } - function it_is_initializable(): void + public function it_is_initializable(): void { $this->shouldHaveType(RenderProductPagesRuntime::class); } - function it_implements_render_product_pages_runtime_interface(): void + public function it_implements_render_product_pages_runtime_interface(): void { $this->shouldHaveType(RenderProductPagesRuntimeInterface::class); } - function it_renders_product_pages( + public function it_renders_product_pages( ChannelContextInterface $channelContext, ProductInterface $product, ChannelInterface $channel, @@ -59,7 +59,7 @@ function it_renders_product_pages( $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); $page->getSections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn("SECTION_CODE"); + $section->getCode()->willReturn('SECTION_CODE'); $pageRepository->findByProduct($product, 'WEB', null)->willReturn([])->shouldBeCalled(); $sectionsSorter->sortBySections([])->willReturn([]); $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); @@ -67,7 +67,7 @@ function it_renders_product_pages( $this->renderProductPages($product)->shouldReturn('content'); } - function it_renders_product_pages_with_sections( + public function it_renders_product_pages_with_sections( ChannelContextInterface $channelContext, ProductInterface $product, ChannelInterface $channel, @@ -80,8 +80,8 @@ function it_renders_product_pages_with_sections( $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); $page->getSections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn("SECTION_CODE"); - $pageRepository->findByProductAndSectionCode($product, 'SECTION_CODE','WEB', null)->willReturn([])->shouldBeCalled(); + $section->getCode()->willReturn('SECTION_CODE'); + $pageRepository->findByProductAndSectionCode($product, 'SECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); $sectionsSorter->sortBySections([])->willReturn([]); $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); diff --git a/src/Assigner/ChannelsAssigner.php b/src/Assigner/ChannelsAssigner.php index 341b63abf..ababfc15b 100644 --- a/src/Assigner/ChannelsAssigner.php +++ b/src/Assigner/ChannelsAssigner.php @@ -17,12 +17,8 @@ final class ChannelsAssigner implements ChannelsAssignerInterface { - /** @var ChannelRepositoryInterface */ - private $channelRepository; - - public function __construct(ChannelRepositoryInterface $channelRepository) + public function __construct(private ChannelRepositoryInterface $channelRepository) { - $this->channelRepository = $channelRepository; } public function assign(ChannelsAwareInterface $channelsAware, array $channelsCodes): void diff --git a/src/Assigner/ProductsAssigner.php b/src/Assigner/ProductsAssigner.php index 72f6f41b4..7b9cacb56 100644 --- a/src/Assigner/ProductsAssigner.php +++ b/src/Assigner/ProductsAssigner.php @@ -17,12 +17,8 @@ final class ProductsAssigner implements ProductsAssignerInterface { - /** @var ProductRepositoryInterface */ - private $productRepository; - - public function __construct(ProductRepositoryInterface $productRepository) + public function __construct(private ProductRepositoryInterface $productRepository) { - $this->productRepository = $productRepository; } public function assign(ProductsAwareInterface $productsAware, array $productsCodes): void diff --git a/src/Assigner/SectionsAssigner.php b/src/Assigner/SectionsAssigner.php index bc2b8fc5b..918b62c62 100644 --- a/src/Assigner/SectionsAssigner.php +++ b/src/Assigner/SectionsAssigner.php @@ -17,12 +17,8 @@ final class SectionsAssigner implements SectionsAssignerInterface { - /** @var SectionRepositoryInterface */ - private $sectionRepository; - - public function __construct(SectionRepositoryInterface $sectionRepository) + public function __construct(private SectionRepositoryInterface $sectionRepository) { - $this->sectionRepository = $sectionRepository; } public function assign(SectionableInterface $sectionsAware, array $sectionsCodes): void diff --git a/src/Assigner/TaxonsAssigner.php b/src/Assigner/TaxonsAssigner.php index 939045a22..021095cb8 100644 --- a/src/Assigner/TaxonsAssigner.php +++ b/src/Assigner/TaxonsAssigner.php @@ -17,12 +17,8 @@ final class TaxonsAssigner implements TaxonsAssignerInterface { - /** @var TaxonRepositoryInterface */ - private $taxonRepository; - - public function __construct(TaxonRepositoryInterface $taxonRepository) + public function __construct(private TaxonRepositoryInterface $taxonRepository) { - $this->taxonRepository = $taxonRepository; } public function assign(TaxonAwareInterface $taxonAware, array $taxonCodes): void diff --git a/src/Command/ImportFromCsvCommand.php b/src/Command/ImportFromCsvCommand.php index ef77a3024..cf1ea18de 100644 --- a/src/Command/ImportFromCsvCommand.php +++ b/src/Command/ImportFromCsvCommand.php @@ -18,14 +18,9 @@ final class ImportFromCsvCommand extends Command { - /** @var ImportProcessorInterface */ - private $importProcessor; - - public function __construct(ImportProcessorInterface $importProcessor) + public function __construct(private ImportProcessorInterface $importProcessor) { parent::__construct(); - - $this->importProcessor = $importProcessor; } protected function configure(): void diff --git a/src/Controller/Action/Admin/ImportDataAction.php b/src/Controller/Action/Admin/ImportDataAction.php index b81c06474..d07601f03 100644 --- a/src/Controller/Action/Admin/ImportDataAction.php +++ b/src/Controller/Action/Admin/ImportDataAction.php @@ -50,8 +50,8 @@ public function __construct( RequestStack $requestStack, FormErrorsFlashHelperInterface $formErrorsFlashHelper, TranslatorInterface $translator, - Environment $twig - ) { + Environment $twig, + ) { $this->importProcessor = $importProcessor; $this->formFactory = $formFactory; $this->requestStack = $requestStack; diff --git a/src/Controller/Action/Admin/ProductSearchAction.php b/src/Controller/Action/Admin/ProductSearchAction.php index 8e0642a06..2181040c9 100644 --- a/src/Controller/Action/Admin/ProductSearchAction.php +++ b/src/Controller/Action/Admin/ProductSearchAction.php @@ -31,8 +31,8 @@ final class ProductSearchAction public function __construct( ProductRepositoryInterface $productRepository, LocaleContextInterface $localeContext, - ViewHandler $viewHandler - ) { + ViewHandler $viewHandler, + ) { $this->productRepository = $productRepository; $this->localeContext = $localeContext; $this->viewHandler = $viewHandler; diff --git a/src/Controller/Action/Admin/RetrievePackageInfoAction.php b/src/Controller/Action/Admin/RetrievePackageInfoAction.php index 9f1a7247e..6c1e1410d 100644 --- a/src/Controller/Action/Admin/RetrievePackageInfoAction.php +++ b/src/Controller/Action/Admin/RetrievePackageInfoAction.php @@ -12,10 +12,10 @@ final class RetrievePackageInfoAction public function __invoke(Request $request): Response { try { - file_get_contents(\sprintf( + $contents = file_get_contents(\sprintf( "https://intranet.bitbag.shop/retrieve-package-info?packageName='%s'&url='%s'", 'bitbag/cms-plugin', - \sprintf('%s://%s', $request->getScheme(), $request->getHttpHost()) + \sprintf('%s://%s', $request->getScheme(), $request->getHttpHost()), )); } catch (\Exception $exception) { return new Response('', Response::HTTP_BAD_REQUEST); diff --git a/src/Controller/Action/Admin/TaxonSearchAction.php b/src/Controller/Action/Admin/TaxonSearchAction.php index 48c468d8e..a6a2fd36e 100644 --- a/src/Controller/Action/Admin/TaxonSearchAction.php +++ b/src/Controller/Action/Admin/TaxonSearchAction.php @@ -31,8 +31,8 @@ final class TaxonSearchAction public function __construct( TaxonRepositoryInterface $taxonRepository, LocaleContextInterface $localeContext, - ViewHandler $viewHandler - ) { + ViewHandler $viewHandler, + ) { $this->taxonRepository = $taxonRepository; $this->localeContext = $localeContext; $this->viewHandler = $viewHandler; diff --git a/src/Controller/Action/Admin/UploadEditorImageAction.php b/src/Controller/Action/Admin/UploadEditorImageAction.php index a540122bf..610398341 100644 --- a/src/Controller/Action/Admin/UploadEditorImageAction.php +++ b/src/Controller/Action/Admin/UploadEditorImageAction.php @@ -35,8 +35,8 @@ final class UploadEditorImageAction public function __construct( MediaProviderResolverInterface $mediaProviderResolver, MediaRepositoryInterface $mediaRepository, - FactoryInterface $mediaFactory - ) { + FactoryInterface $mediaFactory, + ) { $this->mediaProviderResolver = $mediaProviderResolver; $this->mediaRepository = $mediaRepository; $this->mediaFactory = $mediaFactory; diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index 1044d75cc..bce62db51 100755 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -26,7 +26,6 @@ final class MediaController extends ResourceController { use ResourceDataProcessingTrait; - use MediaPageControllersCommonDependencyInjectionsTrait; /** @var MediaResourceResolverInterface */ @@ -67,7 +66,7 @@ public function downloadMediaAction(Request $request): Response $response->setContentDisposition( $request->get('disposition', ResponseHeaderBag::DISPOSITION_ATTACHMENT), - $mediaName + $mediaName, ); $response->headers->set('Content-Type', $media->getMimeType()); diff --git a/src/Controller/PageController.php b/src/Controller/PageController.php index 7e9a5a40d..da031234a 100755 --- a/src/Controller/PageController.php +++ b/src/Controller/PageController.php @@ -23,7 +23,6 @@ final class PageController extends ResourceController { use ResourceDataProcessingTrait; - use MediaPageControllersCommonDependencyInjectionsTrait; /** @var PageResourceResolverInterface */ diff --git a/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php b/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php index 32160c526..239ad5fde 100644 --- a/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php +++ b/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php @@ -12,8 +12,7 @@ final class AuthenticationManagerPolyfillPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { if ( - false === $container->has('security.authentication_manager') - && + false === $container->has('security.authentication_manager') && true === $container->has('security.authentication.manager') ) { $container->setAlias('security.authentication_manager', 'security.authentication.manager'); diff --git a/src/Downloader/ImageDownloader.php b/src/Downloader/ImageDownloader.php index ae47659d7..93743c481 100644 --- a/src/Downloader/ImageDownloader.php +++ b/src/Downloader/ImageDownloader.php @@ -16,12 +16,8 @@ final class ImageDownloader implements ImageDownloaderInterface { - /** @var Filesystem */ - private $filesystem; - - public function __construct(Filesystem $filesystem) + public function __construct(private Filesystem $filesystem) { - $this->filesystem = $filesystem; } public function download(string $url): UploadedFile @@ -29,7 +25,7 @@ public function download(string $url): UploadedFile $path = rtrim(sys_get_temp_dir(), \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . md5(random_bytes(10)); $pathInfo = pathinfo($url); $extension = $pathInfo['extension'] ?? null; - $originalName = $pathInfo['basename'] ?? ''; + $originalName = $pathInfo['basename']; if (null !== $extension) { $path .= '.' . $extension; diff --git a/src/Entity/Block.php b/src/Entity/Block.php index 969b0b38a..e596ac140 100755 --- a/src/Entity/Block.php +++ b/src/Entity/Block.php @@ -17,15 +17,10 @@ class Block implements BlockInterface { use ToggleableTrait; - use SectionableTrait; - use ProductsAwareTrait; - use TaxonAwareTrait; - use ChannelsAwareTrait; - use TranslatableTrait { __construct as protected initializeTranslationsCollection; } diff --git a/src/Entity/FrequentlyAskedQuestion.php b/src/Entity/FrequentlyAskedQuestion.php index 9c60c164d..ac5fcadbf 100755 --- a/src/Entity/FrequentlyAskedQuestion.php +++ b/src/Entity/FrequentlyAskedQuestion.php @@ -17,7 +17,6 @@ class FrequentlyAskedQuestion implements FrequentlyAskedQuestionInterface { use ChannelsAwareTrait; - use ToggleableTrait, TranslatableTrait { __construct as private initializeTranslationsCollection; diff --git a/src/Entity/Media.php b/src/Entity/Media.php index 0661e69b1..afa9b832c 100644 --- a/src/Entity/Media.php +++ b/src/Entity/Media.php @@ -20,13 +20,9 @@ class Media implements MediaInterface { use ToggleableTrait; - use SectionableTrait; - use ProductsAwareTrait; - use ChannelsAwareTrait; - use TranslatableTrait { __construct as protected initializeTranslationsCollection; } diff --git a/src/Entity/Page.php b/src/Entity/Page.php index 2529c4a1f..0e6a3a76e 100755 --- a/src/Entity/Page.php +++ b/src/Entity/Page.php @@ -18,15 +18,10 @@ class Page implements PageInterface { use ToggleableTrait; - use ProductsAwareTrait; - use SectionableTrait; - use TimestampableTrait; - use ChannelsAwareTrait; - use TranslatableTrait { __construct as protected initializeTranslationsCollection; } diff --git a/src/EventListener/MediaUploadListener.php b/src/EventListener/MediaUploadListener.php index 77bee2675..0e1f5b4e7 100755 --- a/src/EventListener/MediaUploadListener.php +++ b/src/EventListener/MediaUploadListener.php @@ -17,12 +17,8 @@ final class MediaUploadListener { - /** @var MediaProviderResolverInterface */ - private $mediaProviderResolver; - - public function __construct(MediaProviderResolverInterface $mediaProviderResolver) + public function __construct(private MediaProviderResolverInterface $mediaProviderResolver) { - $this->mediaProviderResolver = $mediaProviderResolver; } public function uploadMedia(ResourceControllerEvent $event): void diff --git a/src/EventListener/ResourceDeleteSubscriber.php b/src/EventListener/ResourceDeleteSubscriber.php index 772863b15..fc7a3fcd4 100644 --- a/src/EventListener/ResourceDeleteSubscriber.php +++ b/src/EventListener/ResourceDeleteSubscriber.php @@ -23,14 +23,8 @@ final class ResourceDeleteSubscriber implements EventSubscriberInterface { - private UrlGeneratorInterface $router; - - private RequestStack $requestStack; - - public function __construct(UrlGeneratorInterface $router, RequestStack $requestStack) + public function __construct(private UrlGeneratorInterface $router, private RequestStack $requestStack) { - $this->router = $router; - $this->requestStack = $requestStack; } public static function getSubscribedEvents(): array diff --git a/src/Fixture/BlockFixture.php b/src/Fixture/BlockFixture.php index 55bbd21b5..f4222a162 100755 --- a/src/Fixture/BlockFixture.php +++ b/src/Fixture/BlockFixture.php @@ -16,12 +16,8 @@ final class BlockFixture extends AbstractFixture { - /** @var FixtureFactoryInterface */ - private $blockFixtureFactory; - - public function __construct(FixtureFactoryInterface $blockFixtureFactory) + public function __construct(private FixtureFactoryInterface $blockFixtureFactory) { - $this->blockFixtureFactory = $blockFixtureFactory; } public function load(array $options): void diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php index f2acf8c86..5b71860c5 100755 --- a/src/Fixture/Factory/BlockFixtureFactory.php +++ b/src/Fixture/Factory/BlockFixtureFactory.php @@ -25,66 +25,28 @@ final class BlockFixtureFactory implements FixtureFactoryInterface { - /** @var FactoryInterface */ - private $blockFactory; - - /** @var FactoryInterface */ - private $blockTranslationFactory; - - /** @var BlockRepositoryInterface */ - private $blockRepository; - - /** @var ChannelContextInterface */ - private $channelContext; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ProductRepositoryInterface */ - private $productRepository; - - /** @var ProductsAssignerInterface */ - private $productsAssigner; - - /** @var TaxonsAssignerInterface */ - private $taxonsAssigner; - - /** @var SectionsAssignerInterface */ - private $sectionsAssigner; - - /** @var ChannelsAssignerInterface */ - private $channelAssigner; - public function __construct( - FactoryInterface $blockFactory, - FactoryInterface $blockTranslationFactory, - BlockRepositoryInterface $blockRepository, - ProductRepositoryInterface $productRepository, - ChannelContextInterface $channelContext, - LocaleContextInterface $localeContext, - ProductsAssignerInterface $productsAssigner, - TaxonsAssignerInterface $taxonsAssigner, - SectionsAssignerInterface $sectionsAssigner, - ChannelsAssignerInterface $channelAssigner - ) { - $this->blockFactory = $blockFactory; - $this->blockTranslationFactory = $blockTranslationFactory; - $this->blockRepository = $blockRepository; - $this->productRepository = $productRepository; - $this->channelContext = $channelContext; - $this->localeContext = $localeContext; - $this->productsAssigner = $productsAssigner; - $this->taxonsAssigner = $taxonsAssigner; - $this->sectionsAssigner = $sectionsAssigner; - $this->channelAssigner = $channelAssigner; + private FactoryInterface $blockFactory, + private FactoryInterface $blockTranslationFactory, + private BlockRepositoryInterface $blockRepository, + private ProductRepositoryInterface $productRepository, + private ChannelContextInterface $channelContext, + private LocaleContextInterface $localeContext, + private ProductsAssignerInterface $productsAssigner, + private TaxonsAssignerInterface $taxonsAssigner, + private SectionsAssignerInterface $sectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, + ) { } public function load(array $data): void { foreach ($data as $code => $fields) { + /** @var ?BlockInterface $block */ + $block = $this->blockRepository->findOneBy(['code' => $code]); if ( true === $fields['remove_existing'] && - null !== $block = $this->blockRepository->findOneBy(['code' => $code]) + null !== $block ) { $this->blockRepository->remove($block); } @@ -138,7 +100,7 @@ private function resolveProducts(BlockInterface $block, int $limit): void $products = $this->productRepository->findLatestByChannel( $channel, $this->localeContext->getLocaleCode(), - $limit + $limit, ); foreach ($products as $product) { $block->addProduct($product); diff --git a/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php b/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php index 56e01bf15..082fe5170 100755 --- a/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php +++ b/src/Fixture/Factory/FrequentlyAskedQuestionFixtureFactory.php @@ -18,36 +18,22 @@ final class FrequentlyAskedQuestionFixtureFactory implements FixtureFactoryInterface { - /** @var FactoryInterface */ - private $frequentlyAskedQuestionFactory; - - /** @var FactoryInterface */ - private $frequentlyAskedQuestionTranslationFactory; - - /** @var FrequentlyAskedQuestionRepositoryInterface */ - private $frequentlyAskedQuestionRepository; - - /** @var ChannelsAssignerInterface */ - private $channelAssigner; - public function __construct( - FactoryInterface $frequentlyAskedQuestionFactory, - FactoryInterface $frequentlyAskedQuestionTranslationFactory, - FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, - ChannelsAssignerInterface $channelAssigner - ) { - $this->frequentlyAskedQuestionFactory = $frequentlyAskedQuestionFactory; - $this->frequentlyAskedQuestionTranslationFactory = $frequentlyAskedQuestionTranslationFactory; - $this->frequentlyAskedQuestionRepository = $frequentlyAskedQuestionRepository; - $this->channelAssigner = $channelAssigner; + private FactoryInterface $frequentlyAskedQuestionFactory, + private FactoryInterface $frequentlyAskedQuestionTranslationFactory, + private FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, + private ChannelsAssignerInterface $channelAssigner, + ) { } public function load(array $data): void { foreach ($data as $code => $fields) { + /** @var ?FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ + $frequentlyAskedQuestion = $this->frequentlyAskedQuestionRepository->findOneBy(['code' => $code]); if ( true === $fields['remove_existing'] && - null !== $frequentlyAskedQuestion = $this->frequentlyAskedQuestionRepository->findOneBy(['code' => $code]) + null !== $frequentlyAskedQuestion ) { $this->frequentlyAskedQuestionRepository->remove($frequentlyAskedQuestion); } @@ -65,8 +51,8 @@ public function load(array $data): void private function createFrequentlyAskedQuestion( string $code, array $frequentlyAskedQuestionData, - int $position - ): void { + int $position, + ): void { /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ $frequentlyAskedQuestion = $this->frequentlyAskedQuestionFactory->createNew(); diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php index 254cba000..81e1214c0 100644 --- a/src/Fixture/Factory/MediaFixtureFactory.php +++ b/src/Fixture/Factory/MediaFixtureFactory.php @@ -22,51 +22,25 @@ final class MediaFixtureFactory implements FixtureFactoryInterface { - /** @var FactoryInterface */ - private $mediaFactory; - - /** @var FactoryInterface */ - private $mediaTranslationFactory; - - /** @var MediaProviderResolverInterface */ - private $mediaProviderResolver; - - /** @var MediaRepositoryInterface */ - private $mediaRepository; - - /** @var ProductsAssignerInterface */ - private $productsAssigner; - - /** @var SectionsAssignerInterface */ - private $sectionsAssigner; - - /** @var ChannelsAssignerInterface */ - private $channelAssigner; - public function __construct( - FactoryInterface $mediaFactory, - FactoryInterface $mediaTranslationFactory, - MediaProviderResolverInterface $mediaProviderResolver, - MediaRepositoryInterface $mediaRepository, - ProductsAssignerInterface $productsAssigner, - SectionsAssignerInterface $sectionsAssigner, - ChannelsAssignerInterface $channelAssigner - ) { - $this->mediaFactory = $mediaFactory; - $this->mediaTranslationFactory = $mediaTranslationFactory; - $this->mediaProviderResolver = $mediaProviderResolver; - $this->mediaRepository = $mediaRepository; - $this->productsAssigner = $productsAssigner; - $this->sectionsAssigner = $sectionsAssigner; - $this->channelAssigner = $channelAssigner; + private FactoryInterface $mediaFactory, + private FactoryInterface $mediaTranslationFactory, + private MediaProviderResolverInterface $mediaProviderResolver, + private MediaRepositoryInterface $mediaRepository, + private ProductsAssignerInterface $productsAssigner, + private SectionsAssignerInterface $sectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, + ) { } public function load(array $data): void { foreach ($data as $code => $fields) { + /** @var ?MediaInterface $media */ + $media = $this->mediaRepository->findOneBy(['code' => $code]); if ( true === $fields['remove_existing'] && - null !== $media = $this->mediaRepository->findOneBy(['code' => $code]) + null !== $media ) { $this->mediaRepository->remove($media); } diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index 4fb0fbab7..c7c125cd0 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -31,66 +31,28 @@ final class PageFixtureFactory implements FixtureFactoryInterface { public const CHANNEL_WITH_CODE_NOT_FOUND_MESSAGE = 'Channel with code "%s" not found'; - /** @var FactoryInterface */ - private $pageFactory; - - /** @var FactoryInterface */ - private $pageTranslationFactory; - - /** @var PageRepositoryInterface */ - private $pageRepository; - - /** @var MediaProviderResolverInterface */ - private $mediaProviderResolver; - - /** @var ProductRepositoryInterface */ - private $productRepository; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ProductsAssignerInterface */ - private $productsAssigner; - - /** @var SectionsAssignerInterface */ - private $sectionsAssigner; - - /** @var ChannelsAssignerInterface */ - private $channelAssigner; - - /** @var ChannelRepositoryInterface */ - private $channelRepository; - public function __construct( - FactoryInterface $pageFactory, - FactoryInterface $pageTranslationFactory, - PageRepositoryInterface $pageRepository, - MediaProviderResolverInterface $mediaProviderResolver, - ProductsAssignerInterface $productsAssigner, - SectionsAssignerInterface $sectionsAssigner, - ChannelsAssignerInterface $channelAssigner, - ProductRepositoryInterface $productRepository, - LocaleContextInterface $localeContext, - ChannelRepositoryInterface $channelRepository - ) { - $this->pageFactory = $pageFactory; - $this->pageTranslationFactory = $pageTranslationFactory; - $this->pageRepository = $pageRepository; - $this->mediaProviderResolver = $mediaProviderResolver; - $this->productsAssigner = $productsAssigner; - $this->sectionsAssigner = $sectionsAssigner; - $this->channelAssigner = $channelAssigner; - $this->productRepository = $productRepository; - $this->localeContext = $localeContext; - $this->channelRepository = $channelRepository; + private FactoryInterface $pageFactory, + private FactoryInterface $pageTranslationFactory, + private PageRepositoryInterface $pageRepository, + private MediaProviderResolverInterface $mediaProviderResolver, + private ProductsAssignerInterface $productsAssigner, + private SectionsAssignerInterface $sectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, + private ProductRepositoryInterface $productRepository, + private LocaleContextInterface $localeContext, + private ChannelRepositoryInterface $channelRepository, + ) { } public function load(array $data): void { foreach ($data as $code => $fields) { + /** @var ?PageInterface $page */ + $page = $this->pageRepository->findOneBy(['code' => $code]); if ( true === $fields['remove_existing'] && - null !== $page = $this->pageRepository->findOneBy(['code' => $code]) + null !== $page ) { $this->pageRepository->remove($page); } @@ -108,8 +70,8 @@ public function load(array $data): void private function createPage( string $code, array $pageData, - bool $generateSlug = false - ): void { + bool $generateSlug = false, + ): void { /** @var PageInterface $page */ $page = $this->pageFactory->createNew(); $products = $pageData['products']; @@ -161,8 +123,8 @@ private function createPage( private function resolveProductsForChannels( PageInterface $page, int $limit, - array $channelCodes - ): void { + array $channelCodes, + ): void { foreach ($channelCodes as $channelCode) { /** @var ChannelInterface|null $channel */ $channel = $this->channelRepository->findOneByCode($channelCode); @@ -175,12 +137,12 @@ private function resolveProductsForChannels( private function resolveProductsForChannel( PageInterface $page, int $limit, - ChannelInterface $channel - ): void { + ChannelInterface $channel, + ): void { $products = $this->productRepository->findLatestByChannel( $channel, $this->localeContext->getLocaleCode(), - $limit + $limit, ); foreach ($products as $product) { diff --git a/src/Fixture/Factory/SectionFixtureFactory.php b/src/Fixture/Factory/SectionFixtureFactory.php index ee29cc150..4465b4631 100755 --- a/src/Fixture/Factory/SectionFixtureFactory.php +++ b/src/Fixture/Factory/SectionFixtureFactory.php @@ -17,31 +17,21 @@ final class SectionFixtureFactory implements FixtureFactoryInterface { - /** @var FactoryInterface */ - private $sectionFactory; - - /** @var FactoryInterface */ - private $sectionTranslationFactory; - - /** @var SectionRepositoryInterface */ - private $sectionRepository; - public function __construct( - FactoryInterface $sectionFactory, - FactoryInterface $sectionTranslationFactory, - SectionRepositoryInterface $sectionRepository - ) { - $this->sectionFactory = $sectionFactory; - $this->sectionTranslationFactory = $sectionTranslationFactory; - $this->sectionRepository = $sectionRepository; + private FactoryInterface $sectionFactory, + private FactoryInterface $sectionTranslationFactory, + private SectionRepositoryInterface $sectionRepository, + ) { } public function load(array $data): void { foreach ($data as $code => $fields) { + /** @var ?SectionInterface $section */ + $section = $this->sectionRepository->findOneBy(['code' => $code]); if ( true === $fields['remove_existing'] && - null !== $section = $this->sectionRepository->findOneBy(['code' => $code]) + null !== $section ) { $this->sectionRepository->remove($section); } diff --git a/src/Fixture/FrequentlyAskedQuestionFixture.php b/src/Fixture/FrequentlyAskedQuestionFixture.php index 362524ad0..1daabc69f 100755 --- a/src/Fixture/FrequentlyAskedQuestionFixture.php +++ b/src/Fixture/FrequentlyAskedQuestionFixture.php @@ -16,12 +16,8 @@ final class FrequentlyAskedQuestionFixture extends AbstractFixture { - /** @var FixtureFactoryInterface */ - private $frequentlyAskedQuestionFixtureFactory; - - public function __construct(FixtureFactoryInterface $frequentlyAskedQuestionFixtureFactory) + public function __construct(private FixtureFactoryInterface $frequentlyAskedQuestionFixtureFactory) { - $this->frequentlyAskedQuestionFixtureFactory = $frequentlyAskedQuestionFixtureFactory; } public function load(array $options): void diff --git a/src/Fixture/MediaFixture.php b/src/Fixture/MediaFixture.php index b772893fa..4e6d23e02 100644 --- a/src/Fixture/MediaFixture.php +++ b/src/Fixture/MediaFixture.php @@ -16,12 +16,8 @@ final class MediaFixture extends AbstractFixture { - /** @var FixtureFactoryInterface */ - private $mediaFixtureFactory; - - public function __construct(FixtureFactoryInterface $mediaFixtureFactory) + public function __construct(private FixtureFactoryInterface $mediaFixtureFactory) { - $this->mediaFixtureFactory = $mediaFixtureFactory; } public function load(array $options): void diff --git a/src/Fixture/PageFixture.php b/src/Fixture/PageFixture.php index f809c720d..cdd6c5546 100755 --- a/src/Fixture/PageFixture.php +++ b/src/Fixture/PageFixture.php @@ -16,12 +16,8 @@ final class PageFixture extends AbstractFixture { - /** @var FixtureFactoryInterface */ - private $pageFixtureFactory; - - public function __construct(FixtureFactoryInterface $pageFixtureFactory) + public function __construct(private FixtureFactoryInterface $pageFixtureFactory) { - $this->pageFixtureFactory = $pageFixtureFactory; } public function load(array $options): void diff --git a/src/Fixture/SectionFixture.php b/src/Fixture/SectionFixture.php index 17ea7e1d7..3c4e45c23 100755 --- a/src/Fixture/SectionFixture.php +++ b/src/Fixture/SectionFixture.php @@ -16,12 +16,8 @@ final class SectionFixture extends AbstractFixture { - /** @var FixtureFactoryInterface */ - private $sectionFixtureFactory; - - public function __construct(FixtureFactoryInterface $sectionFixtureFactory) + public function __construct(private FixtureFactoryInterface $sectionFixtureFactory) { - $this->sectionFixtureFactory = $sectionFixtureFactory; } public function load(array $options): void diff --git a/src/Form/Type/MediaAutocompleteChoiceType.php b/src/Form/Type/MediaAutocompleteChoiceType.php index 34df1dab7..49c28e018 100644 --- a/src/Form/Type/MediaAutocompleteChoiceType.php +++ b/src/Form/Type/MediaAutocompleteChoiceType.php @@ -39,8 +39,8 @@ public function configureOptions(OptionsResolver $resolver): void public function buildView( FormView $view, FormInterface $form, - array $options - ): void { + array $options, + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; $view->vars['media_type'] = $options['media_type']; diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 3a09e80be..83524b12d 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -29,8 +29,8 @@ final class MediaType extends AbstractResourceType public function __construct( string $dataClass, array $validationGroups = [], - array $providers = [] - ) { + array $providers = [], + ) { parent::__construct($dataClass, $validationGroups); $this->providers = $providers; diff --git a/src/Form/Type/SectionAutocompleteChoiceType.php b/src/Form/Type/SectionAutocompleteChoiceType.php index 03b1ad20d..9b4928619 100755 --- a/src/Form/Type/SectionAutocompleteChoiceType.php +++ b/src/Form/Type/SectionAutocompleteChoiceType.php @@ -30,8 +30,8 @@ public function configureOptions(OptionsResolver $resolver): void public function buildView( FormView $view, FormInterface $form, - array $options - ): void { + array $options, + ): void { $view->vars['remote_criteria_type'] = 'contains'; $view->vars['remote_criteria_name'] = 'phrase'; } diff --git a/src/Importer/AbstractImporter.php b/src/Importer/AbstractImporter.php index 25f8f6646..042767f2d 100755 --- a/src/Importer/AbstractImporter.php +++ b/src/Importer/AbstractImporter.php @@ -15,12 +15,8 @@ abstract class AbstractImporter implements ImporterInterface { - /** @var ValidatorInterface */ - private $validator; - - public function __construct(ValidatorInterface $validator) + public function __construct(private ValidatorInterface $validator) { - $this->validator = $validator; } public function cleanup(): void @@ -39,8 +35,8 @@ protected function getColumnValue(string $column, array $row) protected function getTranslatableColumnValue( string $column, $locale, - array $row - ) { + array $row, + ) { $column = str_replace('__locale__', '_' . $locale, $column); if (array_key_exists($column, $row)) { diff --git a/src/Importer/BlockImporter.php b/src/Importer/BlockImporter.php index 94e862b67..c4cc09613 100644 --- a/src/Importer/BlockImporter.php +++ b/src/Importer/BlockImporter.php @@ -22,41 +22,16 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInterface { - /** @var ResourceResolverInterface */ - private $blockResourceResolver; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ImporterSectionsResolverInterface */ - private $importerSectionsResolver; - - /** @var ImporterChannelsResolverInterface */ - private $importerChannelsResolver; - - /** @var ImporterProductsResolverInterface */ - private $importerProductsResolver; - - /** @var BlockRepositoryInterface */ - private $blockRepository; - public function __construct( - ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, + private ResourceResolverInterface $blockResourceResolver, + private LocaleContextInterface $localeContext, + private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, - BlockRepositoryInterface $blockRepository - ) { + private BlockRepositoryInterface $blockRepository, + ) { parent::__construct($validator); - - $this->blockResourceResolver = $blockResourceResolver; - $this->localeContext = $localeContext; - $this->importerSectionsResolver = $importerSectionsResolver; - $this->importerChannelsResolver = $importerChannelsResolver; - $this->importerProductsResolver = $importerProductsResolver; - $this->blockRepository = $blockRepository; } public function import(array $row): void diff --git a/src/Importer/ImporterChain.php b/src/Importer/ImporterChain.php index 1fd1ff3f9..f6ee7bb33 100644 --- a/src/Importer/ImporterChain.php +++ b/src/Importer/ImporterChain.php @@ -30,7 +30,7 @@ public function getImporterForResource(string $resourceCode): ImporterInterface throw new \UnexpectedValueException(sprintf( 'Importer for %s resource was not found. Make sure getResourceCode in the importer returns proper resource name', - $resourceCode + $resourceCode, )); } } diff --git a/src/Importer/MediaImporter.php b/src/Importer/MediaImporter.php index 4f8c61034..d70848c8b 100644 --- a/src/Importer/MediaImporter.php +++ b/src/Importer/MediaImporter.php @@ -21,36 +21,15 @@ final class MediaImporter extends AbstractImporter implements MediaImporterInterface { - /** @var ResourceResolverInterface */ - private $mediaResourceResolver; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ImporterSectionsResolverInterface */ - private $importerSectionsResolver; - - /** @var ImporterProductsResolverInterface */ - private $importerProductsResolver; - - /** @var MediaRepositoryInterface */ - private $mediaRepository; - public function __construct( - ResourceResolverInterface $mediaResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, + private ResourceResolverInterface $mediaResourceResolver, + private LocaleContextInterface $localeContext, + private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, - MediaRepositoryInterface $mediaRepository - ) { + private MediaRepositoryInterface $mediaRepository, + ) { parent::__construct($validator); - - $this->mediaResourceResolver = $mediaResourceResolver; - $this->localeContext = $localeContext; - $this->importerSectionsResolver = $importerSectionsResolver; - $this->importerProductsResolver = $importerProductsResolver; - $this->mediaRepository = $mediaRepository; } public function import(array $row): void diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php index 0578716ed..531b03e39 100644 --- a/src/Importer/PageImporter.php +++ b/src/Importer/PageImporter.php @@ -28,61 +28,19 @@ final class PageImporter extends AbstractImporter implements PageImporterInterface { - /** @var ResourceResolverInterface */ - private $pageResourceResolver; - - /** @var ResourceResolverInterface */ - private $sectionResolver; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ImageDownloaderInterface */ - private $imageDownloader; - - /** @var FactoryInterface */ - private $mediaFactory; - - /** @var MediaProviderResolverInterface */ - private $mediaProviderResolver; - - /** @var ImporterSectionsResolverInterface */ - private $importerSectionsResolver; - - /** @var ImporterChannelsResolverInterface */ - private $importerChannelsResolver; - - /** @var ImporterProductsResolverInterface */ - private $importerProductsResolver; - - /** @var EntityManagerInterface */ - private $entityManager; - public function __construct( - ResourceResolverInterface $pageResourceResolver, - ResourceResolverInterface $sectionResolver, - LocaleContextInterface $localeContext, - ImageDownloaderInterface $imageDownloader, - FactoryInterface $mediaFactory, - MediaProviderResolverInterface $mediaProviderResolver, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, + private ResourceResolverInterface $pageResourceResolver, + private LocaleContextInterface $localeContext, + private ImageDownloaderInterface $imageDownloader, + private FactoryInterface $mediaFactory, + private MediaProviderResolverInterface $mediaProviderResolver, + private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, - EntityManagerInterface $entityManager - ) { + private EntityManagerInterface $entityManager, + ) { parent::__construct($validator); - - $this->pageResourceResolver = $pageResourceResolver; - $this->sectionResolver = $sectionResolver; - $this->localeContext = $localeContext; - $this->imageDownloader = $imageDownloader; - $this->mediaFactory = $mediaFactory; - $this->mediaProviderResolver = $mediaProviderResolver; - $this->importerSectionsResolver = $importerSectionsResolver; - $this->importerChannelsResolver = $importerChannelsResolver; - $this->importerProductsResolver = $importerProductsResolver; - $this->entityManager = $entityManager; } public function import(array $row): void @@ -112,7 +70,7 @@ public function import(array $row): void $imageCode = $this->getTranslatableColumnValue(self::IMAGE_CODE_COLUMN, $locale, $row); if (null !== $url) { - $this->resolveImage($page, $url ?? '', $locale, $imageCode); + $this->resolveImage($page, $url, $locale, $imageCode); } } @@ -135,8 +93,8 @@ private function resolveImage( PageInterface $page, string $url, string $locale, - string $imageCode - ): void { + string $imageCode, + ): void { $downloadedImage = $this->imageDownloader->download($url); /** @var MediaInterface $image */ diff --git a/src/MediaProvider/GenericProvider.php b/src/MediaProvider/GenericProvider.php index 68aa0e70e..1b111cdcd 100755 --- a/src/MediaProvider/GenericProvider.php +++ b/src/MediaProvider/GenericProvider.php @@ -16,28 +16,12 @@ final class GenericProvider implements ProviderInterface { - /** @var MediaUploaderInterface */ - private $uploader; - - /** @var Environment */ - private $twigEngine; - - /** @var string */ - private $template; - - /** @var string */ - private $pathPrefix; - public function __construct( - MediaUploaderInterface $uploader, - Environment $twigEngine, - string $template, - string $pathPrefix - ) { - $this->uploader = $uploader; - $this->twigEngine = $twigEngine; - $this->template = $template; - $this->pathPrefix = $pathPrefix; + private MediaUploaderInterface $uploader, + private Environment $twigEngine, + private string $template, + private string $pathPrefix, + ) { } public function getTemplate(): string @@ -48,8 +32,8 @@ public function getTemplate(): string public function render( MediaInterface $media, ?string $template = null, - array $options = [] - ): string { + array $options = [], + ): string { return $this->twigEngine->render($template ?? $this->template, array_merge(['media' => $media], $options)); } diff --git a/src/MediaProvider/ProviderInterface.php b/src/MediaProvider/ProviderInterface.php index 9d4bc522b..7c46af390 100644 --- a/src/MediaProvider/ProviderInterface.php +++ b/src/MediaProvider/ProviderInterface.php @@ -19,8 +19,8 @@ public function getTemplate(): string; public function render( MediaInterface $media, ?string $template = null, - array $options = [] - ): string; + array $options = [], + ): string; public function upload(MediaInterface $media): void; } diff --git a/src/Processor/ImportProcessor.php b/src/Processor/ImportProcessor.php index 794bbe4b8..1f660b78b 100644 --- a/src/Processor/ImportProcessor.php +++ b/src/Processor/ImportProcessor.php @@ -17,23 +17,11 @@ final class ImportProcessor implements ImportProcessorInterface { - /** @var ImporterChainInterface */ - private $importerChain; - - /** @var ReaderInterface */ - private $reader; - - /** @var EntityManagerInterface */ - private $entityManager; - public function __construct( - ImporterChainInterface $importerChain, - ReaderInterface $reader, - EntityManagerInterface $entityManager - ) { - $this->importerChain = $importerChain; - $this->reader = $reader; - $this->entityManager = $entityManager; + private ImporterChainInterface $importerChain, + private ReaderInterface $reader, + private EntityManagerInterface $entityManager, + ) { } public function process(string $resourceCode, string $filePath): void diff --git a/src/Repository/BlockRepository.php b/src/Repository/BlockRepository.php index c8aa2e035..5a36615eb 100755 --- a/src/Repository/BlockRepository.php +++ b/src/Repository/BlockRepository.php @@ -42,8 +42,8 @@ public function findEnabledByCode(string $code, string $channelCode): ?BlockInte public function findBySectionCode( string $sectionCode, string $localeCode, - string $channelCode - ): array { + string $channelCode, + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.sections', 'section') @@ -63,8 +63,8 @@ public function findBySectionCode( public function findByProductCode( string $productCode, string $localeCode, - string $channelCode - ): array { + string $channelCode, + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.products', 'product') diff --git a/src/Repository/BlockRepositoryInterface.php b/src/Repository/BlockRepositoryInterface.php index 80d7adeff..0488b33ef 100755 --- a/src/Repository/BlockRepositoryInterface.php +++ b/src/Repository/BlockRepositoryInterface.php @@ -23,12 +23,12 @@ public function findEnabledByCode(string $code, string $channelCode): ?BlockInte public function findBySectionCode( string $sectionCode, string $localeCode, - string $channelCode - ): array; + string $channelCode, + ): array; public function findByProductCode( string $productCode, string $localeCode, - string $channelCode - ): array; + string $channelCode, + ): array; } diff --git a/src/Repository/MediaRepository.php b/src/Repository/MediaRepository.php index ad5d7961a..5b1391da6 100755 --- a/src/Repository/MediaRepository.php +++ b/src/Repository/MediaRepository.php @@ -27,8 +27,8 @@ public function createListQueryBuilder(string $locale): QueryBuilder public function findOneEnabledByCode( string $code, string $localeCode, - string $channelCode - ): ?MediaInterface { + string $channelCode, + ): ?MediaInterface { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.channels', 'channels') @@ -47,8 +47,8 @@ public function findOneEnabledByCode( public function findBySectionCode( string $sectionCode, string $localeCode, - string $channelCode - ): array { + string $channelCode, + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.sections', 'section') @@ -68,8 +68,8 @@ public function findBySectionCode( public function findByProductCode( string $productCode, string $localeCode, - string $channelCode - ): array { + string $channelCode, + ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.products', 'product') diff --git a/src/Repository/MediaRepositoryInterface.php b/src/Repository/MediaRepositoryInterface.php index 41693ad63..27b6ae943 100755 --- a/src/Repository/MediaRepositoryInterface.php +++ b/src/Repository/MediaRepositoryInterface.php @@ -21,18 +21,18 @@ public function createListQueryBuilder(string $locale): QueryBuilder; public function findOneEnabledByCode( string $code, string $localeCode, - string $channelCode - ): ?MediaInterface; + string $channelCode, + ): ?MediaInterface; public function findBySectionCode( string $sectionCode, string $localeCode, - string $channelCode - ): array; + string $channelCode, + ): array; public function findByProductCode( string $productCode, string $localeCode, - string $channelCode - ): array; + string $channelCode, + ): array; } diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php index 3f94487cb..94fd2d201 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -56,8 +56,8 @@ public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageIn public function findOneEnabledBySlugAndChannelCode( string $slug, ?string $localeCode, - string $channelCode - ): ?PageInterface { + string $channelCode, + ): ?PageInterface { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') ->innerJoin('o.channels', 'channels') @@ -104,8 +104,8 @@ public function findBySectionCode(string $sectionCode, ?string $localeCode): arr public function findByProduct( ProductInterface $product, string $channelCode, - ?\DateTimeInterface $date = null - ): array { + ?\DateTimeInterface $date = null, + ): array { $qb = $this->createQueryBuilder('o') ->innerJoin('o.products', 'product') ->innerJoin('o.channels', 'channel') @@ -130,8 +130,8 @@ public function findByProductAndSectionCode( ProductInterface $product, string $sectionCode, string $channelCode, - ?\DateTimeInterface $date = null - ): array { + ?\DateTimeInterface $date = null, + ): array { $qb = $this->createQueryBuilder('o') ->innerJoin('o.products', 'product') ->innerJoin('o.sections', 'section') @@ -160,9 +160,10 @@ private function addDateFilter(QueryBuilder $qb, \DateTimeInterface $date): void ->andWhere( $qb->expr()->orX( 'o.publishAt is NULL', - 'o.publishAt <= :date' - ) + 'o.publishAt <= :date', + ), ) - ->setParameter('date', $date); + ->setParameter('date', $date) + ; } } diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index 49a5f66b5..36f81bb65 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -26,8 +26,8 @@ public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageIn public function findOneEnabledBySlugAndChannelCode( string $slug, ?string $localeCode, - string $channelCode - ): ?PageInterface; + string $channelCode, + ): ?PageInterface; public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder; @@ -36,13 +36,13 @@ public function findBySectionCode(string $sectionCode, ?string $localeCode): arr public function findByProduct( ProductInterface $product, string $channelCode, - ?\DateTimeInterface $date - ): array; + ?\DateTimeInterface $date, + ): array; public function findByProductAndSectionCode( ProductInterface $product, string $sectionCode, string $channelCode, - ?\DateTimeInterface $date - ): array; + ?\DateTimeInterface $date, + ): array; } diff --git a/src/Resolver/BlockResourceResolver.php b/src/Resolver/BlockResourceResolver.php index 66d9ee907..41ffc67eb 100755 --- a/src/Resolver/BlockResourceResolver.php +++ b/src/Resolver/BlockResourceResolver.php @@ -18,23 +18,11 @@ final class BlockResourceResolver implements BlockResourceResolverInterface { - /** @var BlockRepositoryInterface */ - private $blockRepository; - - /** @var LoggerInterface */ - private $logger; - - /** @var ChannelContextInterface */ - private $channelContext; - public function __construct( - BlockRepositoryInterface $blockRepository, - LoggerInterface $logger, - ChannelContextInterface $channelContext - ) { - $this->blockRepository = $blockRepository; - $this->logger = $logger; - $this->channelContext = $channelContext; + private BlockRepositoryInterface $blockRepository, + private LoggerInterface $logger, + private ChannelContextInterface $channelContext, + ) { } public function findOrLog(string $code): ?BlockInterface @@ -46,7 +34,7 @@ public function findOrLog(string $code): ?BlockInterface if (false === $block instanceof BlockInterface) { $this->logger->warning(sprintf( 'Block with "%s" code was not found in the database.', - $code + $code, )); return null; diff --git a/src/Resolver/ImporterChannelsResolver.php b/src/Resolver/ImporterChannelsResolver.php index a1a95828f..917d61d95 100644 --- a/src/Resolver/ImporterChannelsResolver.php +++ b/src/Resolver/ImporterChannelsResolver.php @@ -15,12 +15,8 @@ final class ImporterChannelsResolver implements ImporterChannelsResolverInterface { - /** @var ChannelsAssignerInterface */ - private $channelsAssigner; - - public function __construct(ChannelsAssignerInterface $channelsAssigner) + public function __construct(private ChannelsAssignerInterface $channelsAssigner) { - $this->channelsAssigner = $channelsAssigner; } public function resolve(ChannelsAwareInterface $channelsAware, ?string $channelsRow): void diff --git a/src/Resolver/ImporterProductsResolver.php b/src/Resolver/ImporterProductsResolver.php index 7726fbd59..c9ab83e21 100644 --- a/src/Resolver/ImporterProductsResolver.php +++ b/src/Resolver/ImporterProductsResolver.php @@ -15,12 +15,8 @@ final class ImporterProductsResolver implements ImporterProductsResolverInterface { - /** @var ProductsAssignerInterface */ - private $productsAssigner; - - public function __construct(ProductsAssignerInterface $productsAssigner) + public function __construct(private ProductsAssignerInterface $productsAssigner) { - $this->productsAssigner = $productsAssigner; } public function resolve(ProductsAwareInterface $productsAware, ?string $productsRow): void diff --git a/src/Resolver/ImporterSectionsResolver.php b/src/Resolver/ImporterSectionsResolver.php index f140fa903..a97eebdec 100644 --- a/src/Resolver/ImporterSectionsResolver.php +++ b/src/Resolver/ImporterSectionsResolver.php @@ -15,12 +15,8 @@ final class ImporterSectionsResolver implements ImporterSectionsResolverInterface { - /** @var SectionsAssignerInterface */ - private $sectionsAssigner; - - public function __construct(SectionsAssignerInterface $sectionsAssigner) + public function __construct(private SectionsAssignerInterface $sectionsAssigner) { - $this->sectionsAssigner = $sectionsAssigner; } public function resolve(SectionableInterface $sectionable, ?string $sectionsRow): void diff --git a/src/Resolver/MediaProviderResolver.php b/src/Resolver/MediaProviderResolver.php index 32a90bebe..02c129c1e 100755 --- a/src/Resolver/MediaProviderResolver.php +++ b/src/Resolver/MediaProviderResolver.php @@ -17,12 +17,8 @@ final class MediaProviderResolver implements MediaProviderResolverInterface { - /** @var ServiceRegistryInterface */ - private $providerRegistry; - - public function __construct(ServiceRegistryInterface $providerRegistry) + public function __construct(private ServiceRegistryInterface $providerRegistry) { - $this->providerRegistry = $providerRegistry; } public function resolveProvider(MediaInterface $media): ProviderInterface diff --git a/src/Resolver/MediaResourceResolver.php b/src/Resolver/MediaResourceResolver.php index 9615e7be1..2c58f0ebe 100755 --- a/src/Resolver/MediaResourceResolver.php +++ b/src/Resolver/MediaResourceResolver.php @@ -19,28 +19,12 @@ final class MediaResourceResolver implements MediaResourceResolverInterface { - /** @var MediaRepositoryInterface */ - private $mediaRepository; - - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var ChannelContextInterface */ - private $channelContext; - - /** @var LoggerInterface */ - private $logger; - public function __construct( - MediaRepositoryInterface $mediaRepository, - LocaleContextInterface $localeContext, - ChannelContextInterface $channelContext, - LoggerInterface $logger - ) { - $this->mediaRepository = $mediaRepository; - $this->localeContext = $localeContext; - $this->channelContext = $channelContext; - $this->logger = $logger; + private MediaRepositoryInterface $mediaRepository, + private LocaleContextInterface $localeContext, + private ChannelContextInterface $channelContext, + private LoggerInterface $logger, + ) { } public function findOrLog(string $code): ?MediaInterface @@ -49,13 +33,13 @@ public function findOrLog(string $code): ?MediaInterface $media = $this->mediaRepository->findOneEnabledByCode( $code, $this->localeContext->getLocaleCode(), - $this->channelContext->getChannel()->getCode() + $this->channelContext->getChannel()->getCode(), ); if (false === $media instanceof MediaInterface) { $this->logger->warning(sprintf( 'Media with "%s" code was not found in the database.', - $code + $code, )); return null; diff --git a/src/Resolver/MediaTypeResolver.php b/src/Resolver/MediaTypeResolver.php deleted file mode 100755 index 9554199b1..000000000 --- a/src/Resolver/MediaTypeResolver.php +++ /dev/null @@ -1,29 +0,0 @@ -pageRepository = $pageRepository; - $this->localeContext = $localeContext; - $this->logger = $logger; + private PageRepositoryInterface $pageRepository, + private LocaleContextInterface $localeContext, + private LoggerInterface $logger, + ) { } public function findOrLog(string $code): ?PageInterface @@ -43,7 +31,7 @@ public function findOrLog(string $code): ?PageInterface if (false === $page instanceof PageInterface) { $this->logger->warning(sprintf( 'Page with "%s" code was not found in the database.', - $code + $code, )); return null; diff --git a/src/Resolver/ResourceResolver.php b/src/Resolver/ResourceResolver.php index ad4d9cff0..ebe9e5c31 100644 --- a/src/Resolver/ResourceResolver.php +++ b/src/Resolver/ResourceResolver.php @@ -17,23 +17,11 @@ final class ResourceResolver implements ResourceResolverInterface { - /** @var RepositoryInterface */ - private $repository; - - /** @var FactoryInterface */ - private $factory; - - /** @var string */ - private $uniqueColumn; - public function __construct( - RepositoryInterface $repository, - FactoryInterface $factory, - string $uniqueColumn - ) { - $this->repository = $repository; - $this->factory = $factory; - $this->uniqueColumn = $uniqueColumn; + private RepositoryInterface $repository, + private FactoryInterface $factory, + private string $uniqueColumn, + ) { } /** @@ -47,10 +35,11 @@ public function getResource(string $identifier, string $factoryMethod = 'createN return $resource; } $callback = [$this->factory, $factoryMethod]; - if (!is_callable($callback)) { - throw new BadFunctionCallException('Provided method' . $factoryMethod . ' is not callable'); + + if (is_callable($callback) && method_exists($this->factory, $factoryMethod)) { + return call_user_func($callback); } - return call_user_func($callback); + throw new BadFunctionCallException('Provided method' . $factoryMethod . ' is not callable'); } } diff --git a/src/Resources/config/services/importer.yml b/src/Resources/config/services/importer.yml index 7d50d9521..d2874b62c 100644 --- a/src/Resources/config/services/importer.yml +++ b/src/Resources/config/services/importer.yml @@ -6,7 +6,6 @@ services: class: BitBag\SyliusCmsPlugin\Importer\PageImporter arguments: - "@bitbag_sylius_cms_plugin.resolver.resource.page" - - "@bitbag_sylius_cms_plugin.resolver.resource.section" - "@sylius.context.locale" - "@bitbag_sylius_cms_plugin.downloader.image" - "@bitbag_sylius_cms_plugin.factory.media" diff --git a/src/Resources/config/services/resolver.yml b/src/Resources/config/services/resolver.yml index 60a0af6a7..ca512634a 100644 --- a/src/Resources/config/services/resolver.yml +++ b/src/Resources/config/services/resolver.yml @@ -43,9 +43,6 @@ services: - "@sylius.context.locale" - "@logger" - bitbag_sylius_cms_plugin.resolver.media_type: - class: BitBag\SyliusCmsPlugin\Resolver\MediaTypeResolver - bitbag_sylius_cms_plugin.resolver.media_resource: class: BitBag\SyliusCmsPlugin\Resolver\MediaResourceResolver public: true diff --git a/src/Resources/config/services/sitemap_provider.yml b/src/Resources/config/services/sitemap_provider.yml deleted file mode 100644 index 1f541e927..000000000 --- a/src/Resources/config/services/sitemap_provider.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - bitbag_sylius_cms_plugin.sitemap_provider.page: - class: BitBag\SyliusCmsPlugin\SitemapProvider\PageUrlProvider - arguments: - - "@bitbag_sylius_cms_plugin.repository.page" - - "@router" - - "@sylius.sitemap_url_factory" - - "@sylius.context.locale" - - "@sylius.context.channel" - tags: - - { name: sylius.sitemap_provider } diff --git a/src/Resources/config/services/twig.yml b/src/Resources/config/services/twig.yml index d40be989a..90dd7ffc7 100755 --- a/src/Resources/config/services/twig.yml +++ b/src/Resources/config/services/twig.yml @@ -15,7 +15,6 @@ services: bitbag_sylius_cms_plugin.twig.runtime.block: class: BitBag\SyliusCmsPlugin\Twig\Runtime\RenderBlockRuntime arguments: - - "@bitbag_sylius_cms_plugin.repository.block" - "@bitbag_sylius_cms_plugin.resolver.block_resource" - "@twig" tags: diff --git a/src/SitemapProvider/PageUrlProvider.php b/src/SitemapProvider/PageUrlProvider.php deleted file mode 100644 index 01fa61504..000000000 --- a/src/SitemapProvider/PageUrlProvider.php +++ /dev/null @@ -1,137 +0,0 @@ -pageRepository = $pageRepository; - $this->router = $router; - $this->sitemapUrlFactory = $sitemapUrlFactory; - $this->localeContext = $localeContext; - $this->channelContext = $channelContext; - } - - public function getName(): string - { - return 'cms_pages'; - } - - public function generate(ChannelInterface $channel): iterable - { - $urls = []; - - foreach ($this->getPages() as $page) { - $urls[] = $this->createPageUrl($page); - } - - return $urls; - } - - private function getTranslations(PageInterface $page): Collection - { - return $page->getTranslations()->filter(function (TranslationInterface $translation) { - return $this->localeInLocaleCodes($translation); - }); - } - - private function localeInLocaleCodes(TranslationInterface $translation): bool - { - return in_array($translation->getLocale(), $this->getLocaleCodes()); - } - - private function getPages(): iterable - { - return $this->pageRepository->findEnabled(true); - } - - private function getLocaleCodes(): array - { - /** @var ChannelInterface $channel */ - $channel = $this->channelContext->getChannel(); - - return $channel->getLocales()->map(function (LocaleInterface $locale) { - return $locale->getCode(); - })->toArray(); - } - - private function createPageUrl(PageInterface $page): UrlInterface - { - $location = $this->router->generate('bitbag_sylius_cms_plugin_shop_page_show', [ - 'slug' => $page->getTranslation($this->localeContext->getLocaleCode())->getSlug(), - '_locale' => $this->localeContext->getLocaleCode(), - ]); - - $pageUrl = $this->sitemapUrlFactory->createNew($location); - - $pageUrl->setChangeFrequency(ChangeFrequency::daily()); - $pageUrl->setPriority(0.7); - - if ($page->getUpdatedAt()) { - $pageUrl->setLastModification($page->getUpdatedAt()); - } elseif ($page->getCreatedAt()) { - $pageUrl->setLastModification($page->getCreatedAt()); - } - - /** @var PageTranslationInterface $translation */ - foreach ($this->getTranslations($page) as $translation) { - if (!$translation->getLocale() || !$this->localeInLocaleCodes($translation) || $translation->getLocale() === $this->localeContext->getLocaleCode()) { - continue; - } - - $location = $this->router->generate('bitbag_sylius_cms_plugin_shop_page_show', [ - 'slug' => $translation->getSlug(), - '_locale' => $translation->getLocale(), - ]); - - $pageUrl->addAlternative(new AlternativeUrl($location, $translation->getLocale())); - } - - return $pageUrl; - } -} diff --git a/src/Twig/Extension/RenderBlockExtension.php b/src/Twig/Extension/RenderBlockExtension.php index eeec7ecd8..2236dd3da 100644 --- a/src/Twig/Extension/RenderBlockExtension.php +++ b/src/Twig/Extension/RenderBlockExtension.php @@ -16,12 +16,8 @@ final class RenderBlockExtension extends AbstractExtension { - /** @var RenderBlockRuntimeInterface */ - private $blockRuntime; - - public function __construct(RenderBlockRuntimeInterface $blockRuntime) + public function __construct(private RenderBlockRuntimeInterface $blockRuntime) { - $this->blockRuntime = $blockRuntime; } public function getFunctions(): array diff --git a/src/Twig/Extension/RenderMediaExtension.php b/src/Twig/Extension/RenderMediaExtension.php index d4055df20..02f0fd4e6 100755 --- a/src/Twig/Extension/RenderMediaExtension.php +++ b/src/Twig/Extension/RenderMediaExtension.php @@ -16,12 +16,8 @@ final class RenderMediaExtension extends AbstractExtension { - /** @var RenderMediaRuntimeInterface */ - private $mediaRuntime; - - public function __construct(RenderMediaRuntimeInterface $mediaRuntime) + public function __construct(private RenderMediaRuntimeInterface $mediaRuntime) { - $this->mediaRuntime = $mediaRuntime; } public function getFunctions(): array diff --git a/src/Twig/Extension/RenderProductPagesExtension.php b/src/Twig/Extension/RenderProductPagesExtension.php index 09f956912..bc9b808d1 100644 --- a/src/Twig/Extension/RenderProductPagesExtension.php +++ b/src/Twig/Extension/RenderProductPagesExtension.php @@ -16,12 +16,8 @@ final class RenderProductPagesExtension extends AbstractExtension { - /** @var RenderProductPagesRuntimeInterface */ - private $productPagesRuntime; - - public function __construct(RenderProductPagesRuntimeInterface $productPagesRuntime) + public function __construct(private RenderProductPagesRuntimeInterface $productPagesRuntime) { - $this->productPagesRuntime = $productPagesRuntime; } public function getFunctions(): array diff --git a/src/Twig/Parser/ContentParser.php b/src/Twig/Parser/ContentParser.php index 89b4b13c1..ea4d8c375 100644 --- a/src/Twig/Parser/ContentParser.php +++ b/src/Twig/Parser/ContentParser.php @@ -15,16 +15,8 @@ final class ContentParser implements ContentParserInterface { - /** @var Environment */ - private $twigEnvironment; - - /** @var array */ - private $enabledFunctions; - - public function __construct(Environment $twigEnvironment, array $enabledFunctions) + public function __construct(private Environment $twigEnvironment, private array $enabledFunctions) { - $this->twigEnvironment = $twigEnvironment; - $this->enabledFunctions = $enabledFunctions; } public function parse(string $input): string @@ -75,8 +67,8 @@ private function getFunctionArguments(string $functionName, string $input): ?arr private function callFunction( array $functions, string $functionName, - array $arguments - ): string { + array $arguments, + ): string { Assert::keyExists($functions, $functionName, sprintf('Function %s does not exist!', $functionName)); /** @var \Twig_Function $function */ $function = $functions[$functionName]; diff --git a/src/Twig/Runtime/RenderBlockRuntime.php b/src/Twig/Runtime/RenderBlockRuntime.php index 396b33050..50501ab9d 100644 --- a/src/Twig/Runtime/RenderBlockRuntime.php +++ b/src/Twig/Runtime/RenderBlockRuntime.php @@ -10,31 +10,17 @@ namespace BitBag\SyliusCmsPlugin\Twig\Runtime; -use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface; use BitBag\SyliusCmsPlugin\Resolver\BlockResourceResolverInterface; use Twig\Environment; final class RenderBlockRuntime implements RenderBlockRuntimeInterface { - /** @var BlockRepositoryInterface */ - private $blockRepository; - - /** @var BlockResourceResolverInterface */ - private $blockResourceResolver; - - /** @var Environment */ - private $templatingEngine; - private const DEFAULT_TEMPLATE = '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig'; public function __construct( - BlockRepositoryInterface $blockRepository, - BlockResourceResolverInterface $blockResourceResolver, - Environment $templatingEngine + private BlockResourceResolverInterface $blockResourceResolver, + private Environment $templatingEngine, ) { - $this->blockRepository = $blockRepository; - $this->blockResourceResolver = $blockResourceResolver; - $this->templatingEngine = $templatingEngine; } public function renderBlock(string $code, ?string $template = null): string diff --git a/src/Twig/Runtime/RenderContentRuntime.php b/src/Twig/Runtime/RenderContentRuntime.php index a4ec19ae4..2c3134dde 100644 --- a/src/Twig/Runtime/RenderContentRuntime.php +++ b/src/Twig/Runtime/RenderContentRuntime.php @@ -15,12 +15,8 @@ final class RenderContentRuntime implements RenderContentRuntimeInterface { - /** @var ContentParserInterface */ - private $contentParser; - - public function __construct(ContentParserInterface $contentParser) + public function __construct(private ContentParserInterface $contentParser) { - $this->contentParser = $contentParser; } public function renderContent(ContentableInterface $contentableResource): string diff --git a/src/Twig/Runtime/RenderLinkRuntime.php b/src/Twig/Runtime/RenderLinkRuntime.php index 3e53f2dc2..003512a80 100644 --- a/src/Twig/Runtime/RenderLinkRuntime.php +++ b/src/Twig/Runtime/RenderLinkRuntime.php @@ -19,36 +19,20 @@ final class RenderLinkRuntime implements RenderLinkRuntimeInterface { - /** @var LocaleContextInterface */ - private $localeContext; - - /** @var PageRepositoryInterface */ - private $pageRepository; - - /** @var RouterInterface */ - private $router; - - /** @var string */ - private $defaultTemplate; - public function __construct( - LocaleContextInterface $localeContext, - PageRepositoryInterface $pageRepository, - RouterInterface $router, - string $defaultTemplate - ) { - $this->localeContext = $localeContext; - $this->pageRepository = $pageRepository; - $this->router = $router; - $this->defaultTemplate = $defaultTemplate; + private LocaleContextInterface $localeContext, + private PageRepositoryInterface $pageRepository, + private RouterInterface $router, + private string $defaultTemplate, + ) { } public function renderLinkForCode( Environment $environment, string $code, array $options = [], - ?string $template = null - ): string { + ?string $template = null, + ): string { $page = $this->pageRepository->findOneEnabledByCode($code, $this->localeContext->getLocaleCode()); return $environment->render($template ?? $this->defaultTemplate, [ @@ -59,7 +43,7 @@ public function renderLinkForCode( public function getLinkForCode( string $code, - array $options = [] + array $options = [], ): string { /** @var PageInterface|null $page */ $page = $this->pageRepository->findOneEnabledByCode($code, $this->localeContext->getLocaleCode()); diff --git a/src/Twig/Runtime/RenderLinkRuntimeInterface.php b/src/Twig/Runtime/RenderLinkRuntimeInterface.php index f6443e491..616791859 100644 --- a/src/Twig/Runtime/RenderLinkRuntimeInterface.php +++ b/src/Twig/Runtime/RenderLinkRuntimeInterface.php @@ -19,8 +19,8 @@ public function renderLinkForCode( Environment $environment, string $code, array $options = [], - ?string $template = null - ): string; + ?string $template = null, + ): string; public function getLinkForCode(string $code, array $options = []): string; } diff --git a/src/Twig/Runtime/RenderMediaRuntime.php b/src/Twig/Runtime/RenderMediaRuntime.php index 3c4f92bbd..89900748d 100644 --- a/src/Twig/Runtime/RenderMediaRuntime.php +++ b/src/Twig/Runtime/RenderMediaRuntime.php @@ -15,18 +15,10 @@ final class RenderMediaRuntime implements RenderMediaRuntimeInterface { - /** @var MediaProviderResolverInterface */ - private $mediaProviderResolver; - - /** @var MediaResourceResolverInterface */ - private $mediaResourceResolver; - public function __construct( - MediaProviderResolverInterface $mediaProviderResolver, - MediaResourceResolverInterface $mediaResourceResolver + private MediaProviderResolverInterface $mediaProviderResolver, + private MediaResourceResolverInterface $mediaResourceResolver, ) { - $this->mediaProviderResolver = $mediaProviderResolver; - $this->mediaResourceResolver = $mediaResourceResolver; } public function renderMedia(string $code, ?string $template = null): string diff --git a/src/Twig/Runtime/RenderProductPagesRuntime.php b/src/Twig/Runtime/RenderProductPagesRuntime.php index 459662f33..62a555212 100644 --- a/src/Twig/Runtime/RenderProductPagesRuntime.php +++ b/src/Twig/Runtime/RenderProductPagesRuntime.php @@ -19,28 +19,12 @@ final class RenderProductPagesRuntime implements RenderProductPagesRuntimeInterface { - /** @var PageRepositoryInterface */ - private $pageRepository; - - /** @var ChannelContextInterface */ - private $channelContext; - - /** @var Environment */ - private $templatingEngine; - - /** @var SectionsSorterInterface */ - private $sectionsSorter; - public function __construct( - PageRepositoryInterface $pageRepository, - ChannelContextInterface $channelContext, - Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter - ) { - $this->pageRepository = $pageRepository; - $this->channelContext = $channelContext; - $this->templatingEngine = $templatingEngine; - $this->sectionsSorter = $sectionsSorter; + private PageRepositoryInterface $pageRepository, + private ChannelContextInterface $channelContext, + private Environment $templatingEngine, + private SectionsSorterInterface $sectionsSorter, + ) { } public function renderProductPages(ProductInterface $product, string $sectionCode = null): string diff --git a/src/Uploader/MediaUploader.php b/src/Uploader/MediaUploader.php index 318f2ba3a..bb2e0abe9 100644 --- a/src/Uploader/MediaUploader.php +++ b/src/Uploader/MediaUploader.php @@ -16,12 +16,8 @@ final class MediaUploader implements MediaUploaderInterface { - /** @var Filesystem */ - private $filesystem; - - public function __construct(Filesystem $filesystem) + public function __construct(private Filesystem $filesystem) { - $this->filesystem = $filesystem; } public function upload(MediaInterface $media, string $pathPrefix): void @@ -51,10 +47,13 @@ public function upload(MediaInterface $media, string $pathPrefix): void $file = $media->getFile(); Assert::notNull($file, sprintf('File for media identified by id: "%s" is null', $media->getId())); $mimeType = $media->getMimeType(); - if (null !== $mimeType && false !== strpos($mimeType, 'image')) { - [$width, $height] = getimagesize($file->getPathname()); - $media->setWidth($width); - $media->setHeight($height); + if (null !== $mimeType && str_contains($mimeType, 'image')) { + $sizes = getimagesize($file->getPathname()); + if (false !== $sizes) { + [$width, $height] = $sizes; + $media->setWidth($width); + $media->setHeight($height); + } } $mediaPath = $media->getPath(); @@ -63,7 +62,7 @@ public function upload(MediaInterface $media, string $pathPrefix): void Assert::notFalse($fileContents, sprintf('File contents for file identified by id: "%s" is false', $file->getPath())); $this->filesystem->write( $mediaPath, - $fileContents + $fileContents, ); } @@ -79,14 +78,14 @@ public function remove(string $path): bool private function expandPath( string $path, string $pathPrefix, - ?string $originalName = null - ): string { + ?string $originalName = null, + ): string { return sprintf( '%s/%s/%s/%s', $pathPrefix, substr($path, 0, 2), substr($path, 2, 2), - $originalName ?? substr($path, 4) + $originalName ?? substr($path, 4), ); } diff --git a/src/Validator/FileMatchesTypeValidator.php b/src/Validator/FileMatchesTypeValidator.php index b47c235d8..8977a438d 100644 --- a/src/Validator/FileMatchesTypeValidator.php +++ b/src/Validator/FileMatchesTypeValidator.php @@ -35,13 +35,15 @@ public function validate(mixed $value, Constraint $constraint): void if (MediaInterface::IMAGE_TYPE === $value->getType() && !(str_starts_with($mime, 'image/'))) { $this->context->buildViolation($constraint->messageImage) - ->addViolation(); + ->addViolation() + ; } if (MediaInterface::VIDEO_TYPE === $value->getType() && !(str_starts_with($mime, 'video/'))) { $this->context->buildViolation($constraint->messageVideo) ->atPath($constraint->field) - ->addViolation(); + ->addViolation() + ; } } } diff --git a/tests/Api/Sitemap/Provider/AbstractTestController.php b/tests/Api/Sitemap/Provider/AbstractTestController.php deleted file mode 100644 index 11fad67ff..000000000 --- a/tests/Api/Sitemap/Provider/AbstractTestController.php +++ /dev/null @@ -1,70 +0,0 @@ -locale = new Locale(); - $this->locale->setCode('en_US'); - - $this->getEntityManager()->persist($this->locale); - - $this->secondLocale = new Locale(); - $this->secondLocale->setCode('nl_NL'); - - $this->getEntityManager()->persist($this->secondLocale); - - $this->currency = new Currency(); - $this->currency->setCode('USD'); - - $this->getEntityManager()->persist($this->currency); - - $this->channel = new Channel(); - $this->channel->setCode('US_WEB'); - $this->channel->setName('US Web Store'); - $this->channel->setDefaultLocale($this->locale); - $this->channel->setBaseCurrency($this->currency); - $this->channel->setTaxCalculationStrategy('order_items_based'); - - $this->channel->addLocale($this->locale); - $this->channel->addLocale($this->secondLocale); - - $this->getEntityManager()->persist($this->channel); - $this->getEntityManager()->flush(); - } -} diff --git a/tests/Behat/Context/Api/BlockContext.php b/tests/Behat/Context/Api/BlockContext.php index 79d364579..9822835dc 100644 --- a/tests/Behat/Context/Api/BlockContext.php +++ b/tests/Behat/Context/Api/BlockContext.php @@ -24,7 +24,7 @@ final class BlockContext implements Context public function __construct( ApiClientInterface $apiClient, - ResponseCheckerInterface $responseChecker + ResponseCheckerInterface $responseChecker, ) { $this->apiClient = $apiClient; $this->responseChecker = $responseChecker; @@ -45,9 +45,9 @@ public function iShouldSeeBlocksInTheList(int $count): void { Assert::count( $this->responseChecker->getCollection( - $this->apiClient->getLastResponse() + $this->apiClient->getLastResponse(), ), - $count + $count, ); } @@ -61,9 +61,9 @@ public function iShouldSeeBlockWithCode(string $code): void $this->responseChecker->hasItemWithValue( $this->apiClient->index(Resources::BLOCKS), 'code', - $code + $code, ), - sprintf('There is no blocks with code "%s"', $code) + sprintf('There is no blocks with code "%s"', $code), ); } @@ -77,9 +77,9 @@ public function iShouldSeeBlockName(): void $this->apiClient->getLastResponse(), 'en_US', 'answer', - "That shouldn't exist" + "That shouldn't exist", ), - 'Block has missing name' + 'Block has missing name', ); } @@ -93,9 +93,9 @@ public function iShouldSeeBlockContent(): void $this->apiClient->getLastResponse(), 'en_US', 'content', - 'Hi there!' + 'Hi there!', ), - 'Block has missing content' + 'Block has missing content', ); } } diff --git a/tests/Behat/Context/Api/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Api/FrequentlyAskedQuestionContext.php index 3f55c8561..ce03e0538 100644 --- a/tests/Behat/Context/Api/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Api/FrequentlyAskedQuestionContext.php @@ -25,7 +25,7 @@ final class FrequentlyAskedQuestionContext implements Context public function __construct( ApiClientInterface $apiClient, - ResponseCheckerInterface $responseChecker + ResponseCheckerInterface $responseChecker, ) { $this->apiClient = $apiClient; $this->responseChecker = $responseChecker; @@ -46,9 +46,9 @@ public function iShouldSeeQuestionsInTheList(string $count): void { Assert::count( $this->responseChecker->getCollection( - $this->apiClient->getLastResponse() + $this->apiClient->getLastResponse(), ), - (int) $count + (int) $count, ); } @@ -61,9 +61,9 @@ public function iShouldSeeTheQuestion(string $code): void $this->responseChecker->hasItemWithValue( $this->apiClient->index(Resources::FAQ), 'code', - $code + $code, ), - sprintf('There is no question with code "%s"', $code) + sprintf('There is no question with code "%s"', $code), ); } @@ -85,9 +85,9 @@ public function iShouldSeeQuestionWithRandomText(): void $this->apiClient->getLastResponse(), 'en_US', 'question', - "That shouldn't exist" + "That shouldn't exist", ), - 'Missing question' + 'Missing question', ); } @@ -101,9 +101,9 @@ public function iShouldSeeAnswerWithRandomText(): void $this->apiClient->getLastResponse(), 'en_US', 'answer', - "That shouldn't exist" + "That shouldn't exist", ), - 'Missing answer' + 'Missing answer', ); } } diff --git a/tests/Behat/Context/Api/MediaContext.php b/tests/Behat/Context/Api/MediaContext.php index 1ef8348f4..5b936aa1c 100644 --- a/tests/Behat/Context/Api/MediaContext.php +++ b/tests/Behat/Context/Api/MediaContext.php @@ -25,7 +25,7 @@ final class MediaContext implements Context public function __construct( ApiClientInterface $apiClient, - ResponseCheckerInterface $responseChecker + ResponseCheckerInterface $responseChecker, ) { $this->apiClient = $apiClient; $this->responseChecker = $responseChecker; @@ -46,9 +46,9 @@ public function iShouldSeeMediaInTheList(int $count): void { Assert::count( $this->responseChecker->getCollection( - $this->apiClient->getLastResponse() + $this->apiClient->getLastResponse(), ), - $count + $count, ); } @@ -71,9 +71,9 @@ public function iShouldSeeMediaName(): void $this->apiClient->getLastResponse(), 'en_US', 'content', - "That shouldn't exist" + "That shouldn't exist", ), - 'Missing media' + 'Missing media', ); } } diff --git a/tests/Behat/Context/Api/PageContext.php b/tests/Behat/Context/Api/PageContext.php index cd0edde48..f4c3c37dd 100644 --- a/tests/Behat/Context/Api/PageContext.php +++ b/tests/Behat/Context/Api/PageContext.php @@ -26,7 +26,7 @@ final class PageContext implements Context public function __construct( ApiClientInterface $apiClient, - ResponseCheckerInterface $responseChecker + ResponseCheckerInterface $responseChecker, ) { $this->apiClient = $apiClient; $this->responseChecker = $responseChecker; @@ -47,10 +47,10 @@ public function iShouldSeePageInTheList(int $count): void { Assert::count( $this->responseChecker->getCollection( - $this->apiClient->getLastResponse() + $this->apiClient->getLastResponse(), ), $count, - sprintf('There is no page with name "%s"', $count) + sprintf('There is no page with name "%s"', $count), ); } @@ -64,9 +64,9 @@ public function iShouldSeeThePage(string $page): void $this->apiClient->index(Resources::PAGES), 'en_US', 'name', - $page + $page, ), - sprintf('There is no page with name "%s"', $page) + sprintf('There is no page with name "%s"', $page), ); } @@ -92,9 +92,9 @@ public function iShouldSeeThePageName(string $name): void $this->apiClient->getLastResponse(), 'en_US', 'name', - $name + $name, ), - sprintf('There is no page with name "%s"', $name) + sprintf('There is no page with name "%s"', $name), ); } @@ -108,9 +108,9 @@ public function iShouldSeeThePageContent(string $content): void $this->apiClient->getLastResponse(), 'en_US', 'content', - $content + $content, ), - sprintf('There is no page with content "%s"', $content) + sprintf('There is no page with content "%s"', $content), ); } } diff --git a/tests/Behat/Context/Api/SectionContext.php b/tests/Behat/Context/Api/SectionContext.php index 9f02152be..8e0a993fe 100644 --- a/tests/Behat/Context/Api/SectionContext.php +++ b/tests/Behat/Context/Api/SectionContext.php @@ -25,7 +25,7 @@ final class SectionContext implements Context public function __construct( ApiClientInterface $apiClient, - ResponseCheckerInterface $responseChecker + ResponseCheckerInterface $responseChecker, ) { $this->apiClient = $apiClient; $this->responseChecker = $responseChecker; @@ -46,9 +46,9 @@ public function iShouldSeeSectionsInTheList(int $count): void { Assert::count( $this->responseChecker->getCollection( - $this->apiClient->getLastResponse() + $this->apiClient->getLastResponse(), ), - $count + $count, ); } @@ -71,9 +71,9 @@ public function iShouldSeeSectionName(): void $this->apiClient->getLastResponse(), 'en_US', 'name', - "That shouldn't exist" + "That shouldn't exist", ), - 'Section has missing name' + 'Section has missing name', ); } } diff --git a/tests/Behat/Context/Setup/BlockContext.php b/tests/Behat/Context/Setup/BlockContext.php index 72a822d3a..ba142492d 100755 --- a/tests/Behat/Context/Setup/BlockContext.php +++ b/tests/Behat/Context/Setup/BlockContext.php @@ -36,8 +36,8 @@ public function __construct( SharedStorageInterface $sharedStorage, RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $blockFactory, - BlockRepositoryInterface $blockRepository - ) { + BlockRepositoryInterface $blockRepository, + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->blockFactory = $blockFactory; @@ -78,8 +78,8 @@ public function thereIsABlockWithCodeAndContent(string $code, string $content): private function createBlock( ?string $code = null, ?string $content = null, - ChannelInterface $channel = null - ): BlockInterface { + ChannelInterface $channel = null, + ): BlockInterface { /** @var BlockInterface $block */ $block = $this->blockFactory->createNew(); diff --git a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php index a3f8e1454..b01ebab4b 100755 --- a/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php @@ -33,8 +33,8 @@ public function __construct( SharedStorageInterface $sharedStorage, RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $frequentlyAskedQuestionFactory, - FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository - ) { + FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->frequentlyAskedQuestionFactory = $frequentlyAskedQuestionFactory; @@ -93,8 +93,8 @@ private function createFrequentlyAskedQuestion( ?string $code = null, int $position = null, bool $prefixQuestionWithPosition = false, - ChannelInterface $channel = null - ): FrequentlyAskedQuestionInterface { + ChannelInterface $channel = null, + ): FrequentlyAskedQuestionInterface { /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ $frequentlyAskedQuestion = $this->frequentlyAskedQuestionFactory->createNew(); diff --git a/tests/Behat/Context/Setup/MediaContext.php b/tests/Behat/Context/Setup/MediaContext.php index 32e6ae93f..de7e6f6c9 100755 --- a/tests/Behat/Context/Setup/MediaContext.php +++ b/tests/Behat/Context/Setup/MediaContext.php @@ -57,8 +57,8 @@ public function __construct( EntityManagerInterface $entityManager, ProductRepositoryInterface $productRepository, SectionRepositoryInterface $sectionRepository, - MediaProviderResolverInterface $mediaProviderResolver - ) { + MediaProviderResolverInterface $mediaProviderResolver, + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->mediaFactory = $mediaFactory; @@ -98,8 +98,8 @@ private function createMedia( ?string $name = null, ?string $content = null, ?string $fileType = null, - ChannelInterface $channel = null - ): MediaInterface { + ChannelInterface $channel = null, + ): MediaInterface { /** @var MediaInterface $media */ $media = $this->mediaFactory->createNew(); diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index 5b62c7e98..734350da8 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -60,8 +60,8 @@ public function __construct( EntityManagerInterface $entityManager, ProductRepositoryInterface $productRepository, SectionRepositoryInterface $sectionRepository, - MediaUploaderInterface $mediaUploader - ) { + MediaUploaderInterface $mediaUploader, + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->pageFactory = $pageFactory; @@ -224,8 +224,8 @@ private function createPage( ?string $code = null, ?string $name = null, ?string $content = null, - ChannelInterface $channel = null - ): PageInterface { + ChannelInterface $channel = null, + ): PageInterface { /** @var PageInterface $page */ $page = $this->pageFactory->createNew(); diff --git a/tests/Behat/Context/Setup/SectionContext.php b/tests/Behat/Context/Setup/SectionContext.php index d61523092..048938f59 100755 --- a/tests/Behat/Context/Setup/SectionContext.php +++ b/tests/Behat/Context/Setup/SectionContext.php @@ -33,8 +33,8 @@ public function __construct( SharedStorageInterface $sharedStorage, RandomStringGeneratorInterface $randomStringGenerator, FactoryInterface $sectionFactory, - SectionRepositoryInterface $sectionRepository - ) { + SectionRepositoryInterface $sectionRepository, + ) { $this->sharedStorage = $sharedStorage; $this->randomStringGenerator = $randomStringGenerator; $this->sectionFactory = $sectionFactory; diff --git a/tests/Behat/Context/Transform/BlockContext.php b/tests/Behat/Context/Transform/BlockContext.php index 62af25780..81d8e1db2 100644 --- a/tests/Behat/Context/Transform/BlockContext.php +++ b/tests/Behat/Context/Transform/BlockContext.php @@ -41,7 +41,7 @@ public function getBlockByCode(string $blockCode): BlockInterface Assert::notNull( $block, - sprintf('No blocks has been found with code "%s".', $blockCode) + sprintf('No blocks has been found with code "%s".', $blockCode), ); return $block; diff --git a/tests/Behat/Context/Transform/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Transform/FrequentlyAskedQuestionContext.php index 2b6b59c61..6a0264086 100644 --- a/tests/Behat/Context/Transform/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Transform/FrequentlyAskedQuestionContext.php @@ -21,7 +21,7 @@ final class FrequentlyAskedQuestionContext implements Context private $frequentlyAskedQuestionRepository; public function __construct( - FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository + FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository, ) { $this->frequentlyAskedQuestionRepository = $frequentlyAskedQuestionRepository; } @@ -38,7 +38,7 @@ public function getFAQByCode(string $faqCode): FrequentlyAskedQuestionInterface Assert::notNull( $faq, - sprintf('No FAQs has been found with code "%s".', $faqCode) + sprintf('No FAQs has been found with code "%s".', $faqCode), ); return $faq; diff --git a/tests/Behat/Context/Transform/MediaContext.php b/tests/Behat/Context/Transform/MediaContext.php index c7c2ed7f0..484d7b322 100644 --- a/tests/Behat/Context/Transform/MediaContext.php +++ b/tests/Behat/Context/Transform/MediaContext.php @@ -26,7 +26,7 @@ final class MediaContext implements Context public function __construct( MediaRepositoryInterface $mediaRepositoryInterface, - SharedStorageInterface $sharedStorage + SharedStorageInterface $sharedStorage, ) { $this->mediaRepositoryInterface = $mediaRepositoryInterface; $this->sharedStorage = $sharedStorage; @@ -43,12 +43,12 @@ public function getMediaByCode(string $mediaCode): MediaInterface $media = $this->mediaRepositoryInterface->findOneEnabledByCode( $mediaCode, $this->sharedStorage->get('locale')->getCode(), - $this->sharedStorage->get('channel')->getCode() + $this->sharedStorage->get('channel')->getCode(), ); Assert::notNull( $media, - sprintf('No media has been found with code "%s".', $mediaCode) + sprintf('No media has been found with code "%s".', $mediaCode), ); return $media; diff --git a/tests/Behat/Context/Transform/PageContext.php b/tests/Behat/Context/Transform/PageContext.php index 824a99d67..752e98db3 100644 --- a/tests/Behat/Context/Transform/PageContext.php +++ b/tests/Behat/Context/Transform/PageContext.php @@ -41,7 +41,7 @@ public function getPageByCode(string $pageCode): PageInterface Assert::notNull( $page, - sprintf('No pages has been found with code "%s".', $pageCode) + sprintf('No pages has been found with code "%s".', $pageCode), ); return $page; diff --git a/tests/Behat/Context/Transform/SectionContext.php b/tests/Behat/Context/Transform/SectionContext.php index c38264766..a857f1f12 100644 --- a/tests/Behat/Context/Transform/SectionContext.php +++ b/tests/Behat/Context/Transform/SectionContext.php @@ -41,7 +41,7 @@ public function getSectionByCode(string $sectionCode): SectionInterface Assert::notNull( $section, - sprintf('No sections has been found with code "%s".', $sectionCode) + sprintf('No sections has been found with code "%s".', $sectionCode), ); return $section; diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index d0b4a464c..cd7da0926 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -57,8 +57,8 @@ public function __construct( CreatePageInterface $createPage, UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, - BlockRepositoryInterface $blockRepository - ) { + BlockRepositoryInterface $blockRepository, + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -211,7 +211,7 @@ public function iShouldBeNotifiedThatNewImageBlockHasBeenCreated(): void { $this->notificationChecker->checkNotification( 'Block has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -222,7 +222,7 @@ public function iShouldBeNotifiedThatTheBlockHasBeenSuccessfullyUpdated(): void { $this->notificationChecker->checkNotification( 'Block has been successfully updated.', - NotificationType::success() + NotificationType::success(), ); } @@ -233,7 +233,7 @@ public function iShouldBeNotifiedThatTheBlockHasBeenDeleted(): void { $this->notificationChecker->checkNotification( 'Block has been successfully deleted.', - NotificationType::success() + NotificationType::success(), ); } @@ -255,7 +255,7 @@ public function iShouldBeNotifiedThatCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s cannot be blank.', - trim($field) + trim($field), ))); } } @@ -267,7 +267,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingBlockWithCode(): vo { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing block with this code.', - false + false, )); } @@ -281,7 +281,7 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s can not be longer than', - trim($field) + trim($field), ), false)); } } diff --git a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php index 4df80b6fa..cdd4a13e5 100755 --- a/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php +++ b/tests/Behat/Context/Ui/Admin/FrequentlyAskedQuestionContext.php @@ -52,8 +52,8 @@ public function __construct( IndexPageInterface $indexPage, CreatePageInterface $createPage, UpdatePageInterface $updatePage, - RandomStringGeneratorInterface $randomStringGenerator - ) { + RandomStringGeneratorInterface $randomStringGenerator, + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -159,7 +159,7 @@ public function iShouldBeNotifiedThatANewFrequentlyAskedQuestionHasBeenCreated() { $this->notificationChecker->checkNotification( 'Success Frequently asked question has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -170,7 +170,7 @@ public function iShouldBeNotifiedThatTheFrequentlyAskedQuestionHasBeenDeleted(): { $this->notificationChecker->checkNotification( 'Frequently asked question has been successfully deleted.', - NotificationType::success() + NotificationType::success(), ); } @@ -184,7 +184,7 @@ public function iShouldBeNotifiedThatFieldsCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s cannot be blank.', - trim($field) + trim($field), ))); } } @@ -200,7 +200,7 @@ public function iShouldBeNotifiedThatFieldsAreTooShort(string $fields): void Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s must be at least %d characters long.', trim($field), - 2 + 2, ))); } } @@ -212,7 +212,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingFrequentlyAskedQues { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing FAQ with this code.', - false + false, )); } @@ -223,7 +223,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingFrequentlyAskedQues { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing FAQ with this position.', - false + false, )); } diff --git a/tests/Behat/Context/Ui/Admin/MediaContext.php b/tests/Behat/Context/Ui/Admin/MediaContext.php index bc3c14b4f..77b969dd6 100755 --- a/tests/Behat/Context/Ui/Admin/MediaContext.php +++ b/tests/Behat/Context/Ui/Admin/MediaContext.php @@ -57,8 +57,8 @@ public function __construct( CreatePageInterface $createPage, UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, - MediaRepositoryInterface $mediaRepository - ) { + MediaRepositoryInterface $mediaRepository, + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -125,7 +125,7 @@ public function iShouldBeNotifiedThatNewMediaHasBeenCreated(): void { $this->notificationChecker->checkNotification( 'Media has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -136,7 +136,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingMediaWithCode(): vo { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing media with this code.', - false + false, )); } @@ -150,7 +150,7 @@ public function iShouldBeNotifiedThatFieldsCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s cannot be blank.', - trim($field) + trim($field), ))); } } @@ -178,7 +178,7 @@ public function iShouldBeNotifiedThatFieldsAreTooShort(string $fields): void Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s must be at least %d characters long.', trim($field), - 2 + 2, ))); } } @@ -193,7 +193,7 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s can not be longer than', - trim($field) + trim($field), ), false)); } } diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php index da7e2c1b4..24b96d937 100755 --- a/tests/Behat/Context/Ui/Admin/PageContext.php +++ b/tests/Behat/Context/Ui/Admin/PageContext.php @@ -57,8 +57,8 @@ public function __construct( CreatePageInterface $createPage, UpdatePageInterface $updatePage, RandomStringGeneratorInterface $randomStringGenerator, - PageRepositoryInterface $pageRepository - ) { + PageRepositoryInterface $pageRepository, + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -225,7 +225,7 @@ public function iShouldBeNotifiedThatNewPageWasCreated(): void { $this->notificationChecker->checkNotification( 'Page has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -236,7 +236,7 @@ public function iShouldBeNotifiedThatThePageWasUpdated(): void { $this->notificationChecker->checkNotification( 'Page has been successfully updated.', - NotificationType::success() + NotificationType::success(), ); } @@ -247,7 +247,7 @@ public function iShouldBeNotifiedThatThePageHasBeenDeleted(): void { $this->notificationChecker->checkNotification( 'Page has been successfully deleted.', - NotificationType::success() + NotificationType::success(), ); } @@ -258,7 +258,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingPageWithCode(): voi { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing page with this code.', - false + false, )); } @@ -272,7 +272,7 @@ public function iShouldBeNotifiedThatFieldsCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s cannot be blank.', - trim($field) + trim($field), ))); } } @@ -288,7 +288,7 @@ public function iShouldBeNotifiedThatFieldsAreTooShort(string $fields): void Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s must be at least %d characters long.', trim($field), - 2 + 2, ))); } } @@ -303,7 +303,7 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s can not be longer than', - trim($field) + trim($field), ), false)); } } diff --git a/tests/Behat/Context/Ui/Admin/SectionContext.php b/tests/Behat/Context/Ui/Admin/SectionContext.php index ab899d37a..05162b91f 100755 --- a/tests/Behat/Context/Ui/Admin/SectionContext.php +++ b/tests/Behat/Context/Ui/Admin/SectionContext.php @@ -52,8 +52,8 @@ public function __construct( IndexPageInterface $indexPage, CreatePageInterface $createPage, UpdatePageInterface $updatePage, - RandomStringGeneratorInterface $randomStringGenerator - ) { + RandomStringGeneratorInterface $randomStringGenerator, + ) { $this->sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -147,7 +147,7 @@ public function iShouldBeNotifiedThatFieldsCannotBeBlank(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s cannot be blank.', - trim($field) + trim($field), ))); } } @@ -163,7 +163,7 @@ public function iShouldBeNotifiedThatFieldsAreTooShort(string $fields): void Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s must be at least %d characters long.', trim($field), - 2 + 2, ))); } } @@ -178,7 +178,7 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void foreach ($fields as $field) { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf( '%s can not be longer than', - trim($field) + trim($field), ), false)); } } @@ -190,7 +190,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingSectionWithCode(): { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( 'There is an existing section with this code.', - false + false, )); } @@ -201,7 +201,7 @@ public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void { $this->notificationChecker->checkNotification( 'Section has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -212,7 +212,7 @@ public function iShouldBeNotifiedThatTheSectionHasBeenDeleted(): void { $this->notificationChecker->checkNotification( 'Section has been successfully deleted.', - NotificationType::success() + NotificationType::success(), ); } diff --git a/tests/Behat/Context/Ui/Shop/MediaContext.php b/tests/Behat/Context/Ui/Shop/MediaContext.php index 03943a85e..21f86a950 100644 --- a/tests/Behat/Context/Ui/Shop/MediaContext.php +++ b/tests/Behat/Context/Ui/Shop/MediaContext.php @@ -27,7 +27,7 @@ class MediaContext extends RawMinkContext implements Context public function __construct( MediaRepositoryInterface $mediaRepository, - HomePageInterface $blockHomePage + HomePageInterface $blockHomePage, ) { $this->mediaRepository = $mediaRepository; $this->blockHomePage = $blockHomePage; diff --git a/tests/Behat/Context/Ui/Shop/PageContext.php b/tests/Behat/Context/Ui/Shop/PageContext.php index 19611ed84..53b5ffc0e 100755 --- a/tests/Behat/Context/Ui/Shop/PageContext.php +++ b/tests/Behat/Context/Ui/Shop/PageContext.php @@ -30,8 +30,8 @@ final class PageContext implements Context public function __construct( ShowPageInterface $showPage, IndexPageInterface $indexPage, - SharedStorageInterface $sharedStorage - ) { + SharedStorageInterface $sharedStorage, + ) { $this->showPage = $showPage; $this->indexPage = $indexPage; $this->sharedStorage = $sharedStorage; diff --git a/tests/Behat/Service/FormHelper.php b/tests/Behat/Service/FormHelper.php index 4e21f66e7..6f33c70d0 100644 --- a/tests/Behat/Service/FormHelper.php +++ b/tests/Behat/Service/FormHelper.php @@ -18,15 +18,15 @@ final class FormHelper public static function fillHiddenInput( Session $session, string $id, - $value - ): void { + $value, + ): void { try { $session->executeScript( sprintf( "document.getElementById('%s').value = '%s';", $id, - $value - ) + $value, + ), ); } /** @noinspection PhpRedundantCatchClauseInspection */ diff --git a/tests/Behat/Service/WysiwygHelper.php b/tests/Behat/Service/WysiwygHelper.php index 3d9615284..372f02cbd 100644 --- a/tests/Behat/Service/WysiwygHelper.php +++ b/tests/Behat/Service/WysiwygHelper.php @@ -21,8 +21,8 @@ public static function fillContent( Session $session, DocumentElement $document, string $content, - int $iframeNumber = 1 - ): void { + int $iframeNumber = 1, + ): void { Assert::isInstanceOf($session->getDriver(), ChromeDriver::class); $session->wait(3000); diff --git a/tests/Functional/Api/BlockTest.php b/tests/Functional/Api/BlockTest.php new file mode 100644 index 000000000..302ba9a0d --- /dev/null +++ b/tests/Functional/Api/BlockTest.php @@ -0,0 +1,53 @@ + 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; + + public function setUp(): void + { + $this->loadFixturesFromFile('Api/BlockTest/block.yml'); + } + + public function test_block_response(): void + { + /** @var BlockInterface $block */ + $block = $this->getRepository()->findEnabledByCode('block1-code', 'code'); + $this->client->request('GET', '/api/v2/shop/cms-plugin/blocks/' . $block->getId(), [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/BlockTest/test_it_get_block_by_id', Response::HTTP_OK); + } + + public function test_blocks_response(): void + { + $this->client->request('GET', '/api/v2/shop/cms-plugin/blocks', [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/BlockTest/test_it_get_blocks', Response::HTTP_OK); + } + + private function getRepository(): BlockRepositoryInterface + { + /** @var BlockRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(BlockInterface::class); + + return $repository; + } +} diff --git a/tests/Functional/Api/FrequentlyAskedQuestionTest.php b/tests/Functional/Api/FrequentlyAskedQuestionTest.php new file mode 100644 index 000000000..61640c33b --- /dev/null +++ b/tests/Functional/Api/FrequentlyAskedQuestionTest.php @@ -0,0 +1,45 @@ + 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; + + public function setUp(): void + { + $this->loadFixturesFromFile('Api/FrequentlyAskedQuestionTest/frequently_asked_question.yml'); + } + + public function test_block_response(): void + { + /** @var FrequentlyAskedQuestionInterface $faq */ + $faq = $this->getRepository()->findOneEnabledByCode('faq1-code'); + $this->client->request('GET', '/api/v2/shop/cms-plugin/faq/' . $faq->getId(), [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_question_by_id', Response::HTTP_OK); + } + + private function getRepository(): FrequentlyAskedQuestionRepositoryInterface + { + /** @var FrequentlyAskedQuestionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(FrequentlyAskedQuestionInterface::class); + + return $repository; + } +} diff --git a/tests/Functional/Api/MediaTest.php b/tests/Functional/Api/MediaTest.php new file mode 100644 index 000000000..e235d4d7d --- /dev/null +++ b/tests/Functional/Api/MediaTest.php @@ -0,0 +1,54 @@ + 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; + + public function setUp(): void + { + $this->loadFixturesFromFile('Api/MediaTest/media.yml'); + } + + public function test_media_response(): void + { + /** @var MediaInterface $media */ + $media = $this->getRepository()->findOneEnabledByCode('media1-code', 'en_US', 'code'); + + $this->client->request('GET', '/api/v2/shop/cms-plugin/media/' . $media->getId(), [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/MediaTest/test_it_get_media_by_id', Response::HTTP_OK); + } + + public function test_medias_response(): void + { + $this->client->request('GET', '/api/v2/shop/cms-plugin/media', [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/MediaTest/test_it_get_media', Response::HTTP_OK); + } + + private function getRepository(): MediaRepositoryInterface + { + /** @var MediaRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(MediaInterface::class); + + return $repository; + } +} diff --git a/tests/Functional/Api/PageTest.php b/tests/Functional/Api/PageTest.php new file mode 100644 index 000000000..670982b00 --- /dev/null +++ b/tests/Functional/Api/PageTest.php @@ -0,0 +1,53 @@ + 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; + + public function setUp(): void + { + $this->loadFixturesFromFile('Api/PageTest/page.yml'); + } + + public function test_page_response(): void + { + /** @var PageInterface $page */ + $page = $this->getRepository()->findOneEnabledByCode('page1-code', 'en_US'); + $this->client->request('GET', '/api/v2/shop/cms-plugin/pages/' . $page->getId(), [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/PageTest/test_it_get_page_by_id', Response::HTTP_OK); + } + + public function test_pages_response(): void + { + $this->client->request('GET', '/api/v2/shop/cms-plugin/pages', [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/PageTest/test_it_get_pages', Response::HTTP_OK); + } + + private function getRepository(): PageRepositoryInterface + { + /** @var PageRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(PageInterface::class); + + return $repository; + } +} diff --git a/tests/Functional/Api/SectionTest.php b/tests/Functional/Api/SectionTest.php new file mode 100644 index 000000000..f68e6677d --- /dev/null +++ b/tests/Functional/Api/SectionTest.php @@ -0,0 +1,53 @@ + 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; + + public function setUp(): void + { + $this->loadFixturesFromFile('Api/SectionTest/section.yml'); + } + + public function test_section_response(): void + { + /** @var SectionInterface $section */ + $section = $this->getRepository()->findOneByCode('section1-code', 'en_US'); + $this->client->request('GET', '/api/v2/shop/cms-plugin/sections/' . $section->getId(), [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/SectionTest/test_it_get_section_by_id', Response::HTTP_OK); + } + + public function test_sections_response(): void + { + $this->client->request('GET', '/api/v2/shop/cms-plugin/sections', [], [], self::CONTENT_TYPE_HEADER); + $response = $this->client->getResponse(); + + $this->assertResponse($response, 'Api/SectionTest/test_it_get_sections', Response::HTTP_OK); + } + + private function getRepository(): SectionRepositoryInterface + { + /** @var SectionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(SectionInterface::class); + + return $repository; + } +} diff --git a/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml b/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml new file mode 100644 index 000000000..8fe7d1a68 --- /dev/null +++ b/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml @@ -0,0 +1,134 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\BlockTranslation: + block1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Block: + block1: + code: 'block1-code' + enabled: true + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@block1_translation' + taxons: + - '@taxon' + block2: + code: 'block2-code' + enabled: true + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@block2_translation' + block3: + code: 'block3-code' + enabled: false + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@block3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Functional/DataFixtures/ORM/Api/FrequentlyAskedQuestionTest/frequently_asked_question.yml b/tests/Functional/DataFixtures/ORM/Api/FrequentlyAskedQuestionTest/frequently_asked_question.yml new file mode 100644 index 000000000..8394f9189 --- /dev/null +++ b/tests/Functional/DataFixtures/ORM/Api/FrequentlyAskedQuestionTest/frequently_asked_question.yml @@ -0,0 +1,57 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslation: + frequently_asked_question1_translation: + question: "How many days there are in one year?" + answer: "It may vary depending on whether you are working on a new question" + locale: 'en_US' + frequently_asked_question2_translation: + question: "Who is responsible for the translation" + answer: "Translators are" + locale: 'en_US' + frequently_asked_question3_translation: + question: "What is the date?" + answer: "Dunno" + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestion: + frequently_asked_question1: + code: 'faq1-code' + enabled: true + position: 10 + channels: + - '@channel' + translations: + - '@frequently_asked_question1_translation' + frequently_asked_question2: + code: 'faq2-code' + enabled: true + position: 20 + channels: + - '@channel' + translations: + - '@frequently_asked_question2_translation' + frequently_asked_question3: + code: 'faq3-code' + enabled: false + position: 30 + channels: + - '@channel' + translations: + - '@frequently_asked_question3_translation' diff --git a/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml b/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml new file mode 100644 index 000000000..119becddf --- /dev/null +++ b/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml @@ -0,0 +1,138 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\MediaTranslation: + media1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Media: + media1: + code: 'media1-code' + enabled: true + type: 'image' + path: '/path/to/media1' + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@media1_translation' + media2: + code: 'media2-code' + enabled: true + type: 'image' + path: '/path/to/media2' + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@media2_translation' + media3: + code: 'media3-code' + enabled: false + type: 'image' + path: '/path/to/media3' + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@media3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml b/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml new file mode 100644 index 000000000..a2778e2a8 --- /dev/null +++ b/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml @@ -0,0 +1,141 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\PageTranslation: + page1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + slug: 'translation1_slug_en_US' + metaKeywords: 'html,application' + breadcrumb: '/application/translations_1' + title: 'Amazing article1' + page2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + slug: 'translation2_slug_en_US' + metaKeywords: 'html,application' + breadcrumb: '/application/translations_2' + title: 'Amazing article2' + page3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + slug: 'translation3_slug_en_US' + metaKeywords: 'html,application' + breadcrumb: '/application/translations_3' + title: 'Amazing article3' +BitBag\SyliusCmsPlugin\Entity\Page: + page1: + code: 'page1-code' + enabled: true + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@page1_translation' + page2: + code: 'page2-code' + enabled: true + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@page2_translation' + page3: + code: 'page3-code' + enabled: false + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@page3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml b/tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml new file mode 100644 index 000000000..de388d554 --- /dev/null +++ b/tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml @@ -0,0 +1,42 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\SectionTranslation: + section1_translation: + name: 'translation1_name_en_US' + locale: 'en_US' + section2_translation: + name: 'translation2_name_en_US' + locale: 'en_US' + section3_translation: + name: 'translation3_name_en_US' + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + translations: + - '@section1_translation' + section2: + code: 'section2-code' + translations: + - '@section2_translation' + section3: + code: 'section3-code' + translations: + - '@section3_translation' diff --git a/tests/Fixture/BlockFixtureTest.php b/tests/Functional/Fixture/BlockFixtureTest.php old mode 100755 new mode 100644 similarity index 99% rename from tests/Fixture/BlockFixtureTest.php rename to tests/Functional/Fixture/BlockFixtureTest.php index 8187ec05d..8f5d6454c --- a/tests/Fixture/BlockFixtureTest.php +++ b/tests/Functional/Fixture/BlockFixtureTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Fixture; +namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\BlockFixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; diff --git a/tests/Fixture/FrequentlyAskedQuestionFixtureTest.php b/tests/Functional/Fixture/FrequentlyAskedQuestionFixtureTest.php old mode 100755 new mode 100644 similarity index 99% rename from tests/Fixture/FrequentlyAskedQuestionFixtureTest.php rename to tests/Functional/Fixture/FrequentlyAskedQuestionFixtureTest.php index 344dd8c19..485d29bd8 --- a/tests/Fixture/FrequentlyAskedQuestionFixtureTest.php +++ b/tests/Functional/Fixture/FrequentlyAskedQuestionFixtureTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Fixture; +namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use BitBag\SyliusCmsPlugin\Fixture\FrequentlyAskedQuestionFixture; diff --git a/tests/Fixture/MediaFixtureTest.php b/tests/Functional/Fixture/MediaFixtureTest.php similarity index 99% rename from tests/Fixture/MediaFixtureTest.php rename to tests/Functional/Fixture/MediaFixtureTest.php index ea1a00447..df1fbabce 100644 --- a/tests/Fixture/MediaFixtureTest.php +++ b/tests/Functional/Fixture/MediaFixtureTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Fixture; +namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use BitBag\SyliusCmsPlugin\Fixture\MediaFixture; diff --git a/tests/Fixture/PageFixtureTest.php b/tests/Functional/Fixture/PageFixtureTest.php old mode 100755 new mode 100644 similarity index 99% rename from tests/Fixture/PageFixtureTest.php rename to tests/Functional/Fixture/PageFixtureTest.php index fd2f1d9fc..01ea7e44a --- a/tests/Fixture/PageFixtureTest.php +++ b/tests/Functional/Fixture/PageFixtureTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Fixture; +namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use BitBag\SyliusCmsPlugin\Fixture\PageFixture; diff --git a/tests/Fixture/SectionFixtureTest.php b/tests/Functional/Fixture/SectionFixtureTest.php old mode 100755 new mode 100644 similarity index 98% rename from tests/Fixture/SectionFixtureTest.php rename to tests/Functional/Fixture/SectionFixtureTest.php index db123f6fe..d4cd3d19d --- a/tests/Fixture/SectionFixtureTest.php +++ b/tests/Functional/Fixture/SectionFixtureTest.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Fixture; +namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use BitBag\SyliusCmsPlugin\Fixture\SectionFixture; diff --git a/tests/Functional/FunctionalTestCase.php b/tests/Functional/FunctionalTestCase.php new file mode 100644 index 000000000..a1d25b996 --- /dev/null +++ b/tests/Functional/FunctionalTestCase.php @@ -0,0 +1,36 @@ +dataFixturesPath = __DIR__ . \DIRECTORY_SEPARATOR . 'DataFixtures' . \DIRECTORY_SEPARATOR . 'ORM'; + $this->expectedResponsesPath = __DIR__ . \DIRECTORY_SEPARATOR . 'Responses' . \DIRECTORY_SEPARATOR . 'Expected'; + $this->filesPath = __DIR__ . \DIRECTORY_SEPARATOR . 'Resources' . \DIRECTORY_SEPARATOR . 'files'; + } + + public function getFilePath(string $fileName): string + { + return $this->filesPath . \DIRECTORY_SEPARATOR . $fileName; + } +} diff --git a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json new file mode 100644 index 000000000..71e6a0e79 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json @@ -0,0 +1,36 @@ +{ + "@context": "/api/v2/contexts/Block", + "@id": "/api/v2/shop/cms-plugin/blocks/@integer@", + "@type": "Block", + "id": "@integer@", + "code": "block1-code", + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "BlockTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "link": "translation_link_en_US" + } + }, + "taxons": [ + { + "@id": "/api/v2/shop/taxons/menu_category", + "@type": "Taxon" + } + ] +} diff --git a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json new file mode 100644 index 000000000..12067ef32 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json @@ -0,0 +1,103 @@ +{ + "@context": "/api/v2/contexts/Block", + "@id": "/api/v2/shop/cms-plugin/blocks", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/blocks/@integer@", + "@type": "Block", + "id": "@integer@", + "code": "block1-code", + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "BlockTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "link": "translation_link_en_US" + } + }, + "taxons": [ + { + "@id": "/api/v2/shop/taxons/menu_category", + "@type": "Taxon" + } + ] + }, + { + "@id": "/api/v2/shop/cms-plugin/blocks/@integer@", + "@type": "Block", + "id": "@integer@", + "code": "block2-code", + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section2-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW2" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "BlockTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "link": "translation_link_en_US" + } + }, + "taxons": [] + }, + { + "@id": "/api/v2/shop/cms-plugin/blocks/@integer@", + "@type": "Block", + "id": "@integer@", + "code": "block3-code", + "enabled": false, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section3-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW3" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "BlockTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "link": "translation_link_en_US" + } + }, + "taxons": [] + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_question_by_id.json b/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_question_by_id.json new file mode 100644 index 000000000..9f732eff1 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_question_by_id.json @@ -0,0 +1,19 @@ +{ + "@context": "/api/v2/contexts/FrequentlyAskedQuestion", + "@id": "/api/v2/shop/cms-plugin/faq/@integer@", + "@type": "FrequentlyAskedQuestion", + "id": "@integer@", + "code": "faq1-code", + "position": 10, + "channels": [ + "/api/v2/shop/channels/code" + ], + "enabled": true, + "translations": { + "en_US": { + "@type": "FrequentlyAskedQuestionTranslation", + "question": "How many days there are in one year?", + "answer": "It may vary depending on whether you are working on a new question" + } + } +} diff --git a/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_questions.json b/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_questions.json new file mode 100644 index 000000000..65fab508c --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/FrequentlyAskedQuestionTest/test_it_get_frequently_asked_questions.json @@ -0,0 +1,62 @@ +{ + "@context": "/api/v2/contexts/FrequentlyAskedQuestion", + "@id": "/api/v2/shop/cms-plugin/faq", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/faq/@integer@", + "@type": "FrequentlyAskedQuestion", + "id": "@integer@", + "code": "faq1-code", + "position": 10, + "channels": [ + "/api/v2/shop/channels/code" + ], + "enabled": true, + "translations": { + "en_US": { + "@type": "FrequentlyAskedQuestionTranslation", + "question": "How many days there are in one year?", + "answer": "It may vary depending on whether you are working on a new question" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/faq/@integer@", + "@type": "FrequentlyAskedQuestion", + "id": "@integer@", + "code": "faq2-code", + "position": 20, + "channels": [ + "/api/v2/shop/channels/code" + ], + "enabled": true, + "translations": { + "en_US": { + "@type": "FrequentlyAskedQuestionTranslation", + "question": "Who is responsible for the translation", + "answer": "Translators are" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/faq/@integer@", + "@type": "FrequentlyAskedQuestion", + "id": "@integer@", + "code": "faq3-code", + "position": 30, + "channels": [ + "/api/v2/shop/channels/code" + ], + "enabled": false, + "translations": { + "en_US": { + "@type": "FrequentlyAskedQuestionTranslation", + "question": "What is the date?", + "answer": "Dunno" + } + } + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json new file mode 100644 index 000000000..59ebcc373 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json @@ -0,0 +1,116 @@ +{ + "@context": "/api/v2/contexts/Media", + "@id": "/api/v2/shop/cms-plugin/media", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/media/@integer@", + "@type": "Media", + "id": "@integer@", + "type": "image", + "code": "media1-code", + "path": "/path/to/media1", + "mimeType": null, + "width": null, + "height": null, + "saveWithOriginalName": false, + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "MediaTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "alt": null, + "link": "translation_link_en_US" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/media/@integer@", + "@type": "Media", + "id": "@integer@", + "type": "image", + "code": "media2-code", + "path": "/path/to/media2", + "mimeType": null, + "width": null, + "height": null, + "saveWithOriginalName": false, + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section2-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW2" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "MediaTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "alt": null, + "link": "translation_link_en_US" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/media/@integer@", + "@type": "Media", + "id": "@integer@", + "type": "image", + "code": "media3-code", + "path": "/path/to/media3", + "mimeType": null, + "width": null, + "height": null, + "saveWithOriginalName": false, + "enabled": false, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section3-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW3" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "MediaTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "alt": null, + "link": "translation_link_en_US" + } + } + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json new file mode 100644 index 000000000..e72cc1fb6 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json @@ -0,0 +1,37 @@ +{ + "@context": "/api/v2/contexts/Media", + "@id": "/api/v2/shop/cms-plugin/media/@integer@", + "@type": "Media", + "id": "@integer@", + "type": "image", + "code": "media1-code", + "path": "/path/to/media1", + "mimeType": null, + "width": null, + "height": null, + "saveWithOriginalName": false, + "enabled": true, + "sections": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" + } + ], + "products": [ + "/api/v2/shop/products/MUG_SW" + ], + "channels": [ + "/api/v2/shop/channels/code" + ], + "translations": { + "en_US": { + "@type": "MediaTranslation", + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "alt": null, + "link": "translation_link_en_US" + } + } +} diff --git a/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_page_by_id.json b/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_page_by_id.json new file mode 100644 index 000000000..b30d87a5b --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_page_by_id.json @@ -0,0 +1,24 @@ +{ + "@context": "/api/v2/contexts/Page", + "@id": "/api/v2/shop/cms-plugin/pages/@integer@", + "@type": "Page", + "id": "@integer@", + "code": "page1-code", + "publishAt": null, + "translations": { + "en_US": { + "@type": "PageTranslation", + "id": "@integer@", + "slug": "translation1_slug_en_US", + "image": null, + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "metaKeywords": "html,application", + "metaDescription": null, + "nameWhenLinked": null, + "descriptionWhenLinked": null, + "breadcrumb": "/application/translations_1", + "title": "Amazing article1" + } + } +} diff --git a/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_pages.json b/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_pages.json new file mode 100644 index 000000000..e8e25fda5 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/PageTest/test_it_get_pages.json @@ -0,0 +1,77 @@ +{ + "@context": "/api/v2/contexts/Page", + "@id": "/api/v2/shop/cms-plugin/pages", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/pages/@integer@", + "@type": "Page", + "id": "@integer@", + "code": "page1-code", + "publishAt": null, + "translations": { + "en_US": { + "@type": "PageTranslation", + "id": "@integer@", + "slug": "translation1_slug_en_US", + "image": null, + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "metaKeywords": "html,application", + "metaDescription": null, + "nameWhenLinked": null, + "descriptionWhenLinked": null, + "breadcrumb": "/application/translations_1", + "title": "Amazing article1" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/pages/@integer@", + "@type": "Page", + "id": "@integer@", + "code": "page2-code", + "publishAt": null, + "translations": { + "en_US": { + "@type": "PageTranslation", + "id": "@integer@", + "slug": "translation2_slug_en_US", + "image": null, + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "metaKeywords": "html,application", + "metaDescription": null, + "nameWhenLinked": null, + "descriptionWhenLinked": null, + "breadcrumb": "/application/translations_2", + "title": "Amazing article2" + } + } + }, + { + "@id": "/api/v2/shop/cms-plugin/pages/@integer@", + "@type": "Page", + "id": "@integer@", + "code": "page3-code", + "publishAt": null, + "translations": { + "en_US": { + "@type": "PageTranslation", + "id": "@integer@", + "slug": "translation3_slug_en_US", + "image": null, + "name": "translation_name_en_US", + "content": "translation_content_en_US", + "metaKeywords": "html,application", + "metaDescription": null, + "nameWhenLinked": null, + "descriptionWhenLinked": null, + "breadcrumb": "/application/translations_3", + "title": "Amazing article3" + } + } + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json new file mode 100644 index 000000000..ea79e6526 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json @@ -0,0 +1,7 @@ +{ + "@context": "/api/v2/contexts/Section", + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" +} diff --git a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json new file mode 100644 index 000000000..1e2715f58 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json @@ -0,0 +1,26 @@ +{ + "@context": "/api/v2/contexts/Section", + "@id": "/api/v2/shop/cms-plugin/sections", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section1-code" + }, + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section2-code" + }, + { + "@id": "/api/v2/shop/cms-plugin/sections/@integer@", + "@type": "Section", + "id": "@integer@", + "code": "section3-code" + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_code.yml b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_code.yml new file mode 100644 index 000000000..9f31ba378 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_code.yml @@ -0,0 +1,36 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\Block: + block1: + code: 'block1-code' + enabled: true + channels: + - '@channel' + block2: + code: 'block2-code' + enabled: true + channels: + - '@channel' + block3: + code: 'block3-code' + enabled: false + channels: + - '@channel' + diff --git a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml new file mode 100644 index 000000000..547e3ae7d --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml @@ -0,0 +1,132 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\BlockTranslation: + block1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Block: + block1: + code: 'block1-code' + enabled: true + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@block1_translation' + block2: + code: 'block2-code' + enabled: true + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@block2_translation' + block3: + code: 'block3-code' + enabled: false + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@block3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml new file mode 100644 index 000000000..e752e060b --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml @@ -0,0 +1,71 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\BlockTranslation: + block1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + block3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Block: + block1: + code: 'block1-code' + enabled: true + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@block1_translation' + block2: + code: 'block2-code' + enabled: true + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@block2_translation' + block3: + code: 'block3-code' + enabled: false + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@block3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_code.yml b/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_code.yml new file mode 100644 index 000000000..8394f9189 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_code.yml @@ -0,0 +1,57 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslation: + frequently_asked_question1_translation: + question: "How many days there are in one year?" + answer: "It may vary depending on whether you are working on a new question" + locale: 'en_US' + frequently_asked_question2_translation: + question: "Who is responsible for the translation" + answer: "Translators are" + locale: 'en_US' + frequently_asked_question3_translation: + question: "What is the date?" + answer: "Dunno" + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestion: + frequently_asked_question1: + code: 'faq1-code' + enabled: true + position: 10 + channels: + - '@channel' + translations: + - '@frequently_asked_question1_translation' + frequently_asked_question2: + code: 'faq2-code' + enabled: true + position: 20 + channels: + - '@channel' + translations: + - '@frequently_asked_question2_translation' + frequently_asked_question3: + code: 'faq3-code' + enabled: false + position: 30 + channels: + - '@channel' + translations: + - '@frequently_asked_question3_translation' diff --git a/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_position.yml b/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_position.yml new file mode 100644 index 000000000..8394f9189 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_position.yml @@ -0,0 +1,57 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslation: + frequently_asked_question1_translation: + question: "How many days there are in one year?" + answer: "It may vary depending on whether you are working on a new question" + locale: 'en_US' + frequently_asked_question2_translation: + question: "Who is responsible for the translation" + answer: "Translators are" + locale: 'en_US' + frequently_asked_question3_translation: + question: "What is the date?" + answer: "Dunno" + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestion: + frequently_asked_question1: + code: 'faq1-code' + enabled: true + position: 10 + channels: + - '@channel' + translations: + - '@frequently_asked_question1_translation' + frequently_asked_question2: + code: 'faq2-code' + enabled: true + position: 20 + channels: + - '@channel' + translations: + - '@frequently_asked_question2_translation' + frequently_asked_question3: + code: 'faq3-code' + enabled: false + position: 30 + channels: + - '@channel' + translations: + - '@frequently_asked_question3_translation' diff --git a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_code.yml b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_code.yml new file mode 100644 index 000000000..e9331380a --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_code.yml @@ -0,0 +1,64 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\MediaTranslation: + media1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Media: + media1: + code: 'media1-code' + enabled: true + type: 'image' + path: '/path/to/media1' + channels: + - '@channel' + translations: + - '@media1_translation' + media2: + code: 'media2-code' + enabled: true + type: 'image' + path: '/path/to/media2' + channels: + - '@channel' + translations: + - '@media2_translation' + media3: + code: 'media3-code' + enabled: false + type: 'image' + path: '/path/to/media3' + channels: + - '@channel' + translations: + - '@media3_translation' + diff --git a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml new file mode 100644 index 000000000..119becddf --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml @@ -0,0 +1,138 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\MediaTranslation: + media1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Media: + media1: + code: 'media1-code' + enabled: true + type: 'image' + path: '/path/to/media1' + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@media1_translation' + media2: + code: 'media2-code' + enabled: true + type: 'image' + path: '/path/to/media2' + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@media2_translation' + media3: + code: 'media3-code' + enabled: false + type: 'image' + path: '/path/to/media3' + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@media3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml new file mode 100644 index 000000000..b8b199975 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml @@ -0,0 +1,77 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\MediaTranslation: + media1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' + media3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + link: 'translation_link_en_US' +BitBag\SyliusCmsPlugin\Entity\Media: + media1: + code: 'media1-code' + enabled: true + type: 'image' + path: '/path/to/media1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@media1_translation' + media2: + code: 'media2-code' + enabled: true + type: 'image' + path: '/path/to/media2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@media2_translation' + media3: + code: 'media3-code' + enabled: false + type: 'image' + path: '/path/to/media3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@media3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_code.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_code.yml new file mode 100644 index 000000000..a3a8cd11c --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_code.yml @@ -0,0 +1,54 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\PageTranslation: + page1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' +BitBag\SyliusCmsPlugin\Entity\Page: + page1: + code: 'page1-code' + enabled: true + channels: + - '@channel' + translations: + - '@page1_translation' + page2: + code: 'page2-code' + enabled: true + channels: + - '@channel' + translations: + - '@page2_translation' + page3: + code: 'page3-code' + enabled: false + channels: + - '@channel' + translations: + - '@page3_translation' diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product.yml new file mode 100644 index 000000000..3bfbbaf9e --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product.yml @@ -0,0 +1,116 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\PageTranslation: + page1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' +BitBag\SyliusCmsPlugin\Entity\Page: + page1: + code: 'page1-code' + enabled: true + products: + - '@product1' + channels: + - '@channel' + translations: + - '@page1_translation' + page2: + code: 'page2-code' + enabled: true + products: + - '@product2' + channels: + - '@channel' + translations: + - '@page2_translation' + page3: + code: 'page3-code' + enabled: false + products: + - '@product3' + channels: + - '@channel' + translations: + - '@page3_translation' + diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml new file mode 100644 index 000000000..d535b07bc --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml @@ -0,0 +1,129 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +Sylius\Component\Taxonomy\Model\TaxonTranslation: + taxon_translation: + locale: 'en_US' + name: "taxon-trans" + slug: "taxon-slug" +Sylius\Component\Core\Model\Taxon: + taxon: + code: "menu_category" + translations: + - '@taxon_translation' + enabled: true +Sylius\Component\Core\Model\ProductTranslation: + first_product_US_translation: + name: 'test_name1' + slug: 'test_slug1' + locale: 'en_US' + second_product_US_translation: + name: 'test_name2' + slug: 'test_slug2' + locale: 'en_US' + third_product_US_translation: + name: 'test_name3' + slug: 'test_slug3' + locale: 'en_US' +Sylius\Component\Core\Model\Product: + product1: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW" + translations: + - "@first_product_US_translation" + product2: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW2" + translations: + - "@second_product_US_translation" + product3: + fallbackLocale: "en_US" + currentLocale: "en_US" + code: "MUG_SW3" + translations: + - "@third_product_US_translation" +Sylius\Component\Core\Model\ProductTaxon: + first_relation: + taxon: '@taxon' + product: '@product1' + second_relation: + taxon: '@taxon' + product: '@product2' +Sylius\Component\Core\Model\ProductVariant: + product_variant1: + product: '@product1' + code: "code1" + +BitBag\SyliusCmsPlugin\Entity\PageTranslation: + page1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' +BitBag\SyliusCmsPlugin\Entity\Page: + page1: + code: 'page1-code' + enabled: true + products: + - '@product1' + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@page1_translation' + page2: + code: 'page2-code' + enabled: true + products: + - '@product2' + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@page2_translation' + page3: + code: 'page3-code' + enabled: false + products: + - '@product3' + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@page3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml new file mode 100644 index 000000000..41d253e76 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml @@ -0,0 +1,68 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\PageTranslation: + page1_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page2_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' + page3_translation: + name: 'translation_name_en_US' + locale: 'en_US' + content: 'translation_content_en_US' +BitBag\SyliusCmsPlugin\Entity\Page: + page1: + code: 'page1-code' + enabled: true + sections: + - '@section1' + channels: + - '@channel' + translations: + - '@page1_translation' + page2: + code: 'page2-code' + enabled: true + sections: + - '@section2' + channels: + - '@channel' + translations: + - '@page2_translation' + page3: + code: 'page3-code' + enabled: false + sections: + - '@section3' + channels: + - '@channel' + translations: + - '@page3_translation' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + section2: + code: 'section2-code' + section3: + code: 'section3-code' + diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml new file mode 100644 index 000000000..de388d554 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml @@ -0,0 +1,42 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\SectionTranslation: + section1_translation: + name: 'translation1_name_en_US' + locale: 'en_US' + section2_translation: + name: 'translation2_name_en_US' + locale: 'en_US' + section3_translation: + name: 'translation3_name_en_US' + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + translations: + - '@section1_translation' + section2: + code: 'section2-code' + translations: + - '@section2_translation' + section3: + code: 'section3-code' + translations: + - '@section3_translation' diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml new file mode 100644 index 000000000..de388d554 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml @@ -0,0 +1,42 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\SectionTranslation: + section1_translation: + name: 'translation1_name_en_US' + locale: 'en_US' + section2_translation: + name: 'translation2_name_en_US' + locale: 'en_US' + section3_translation: + name: 'translation3_name_en_US' + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + translations: + - '@section1_translation' + section2: + code: 'section2-code' + translations: + - '@section2_translation' + section3: + code: 'section3-code' + translations: + - '@section3_translation' diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml new file mode 100644 index 000000000..de388d554 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml @@ -0,0 +1,42 @@ +Sylius\Component\Addressing\Model\Country: + USA: + code: 'US' +Sylius\Component\Currency\Model\Currency: + dollar: + code: 'USD' +Sylius\Component\Locale\Model\Locale: + locale: + createdAt: '' + code: 'en_US' +Sylius\Component\Core\Model\Channel: + channel: + code: "code" + name: "name" + locales: + - '@locale' + default_locale: '@locale' + tax_calculation_strategy: 'order_items_based' + base_currency: '@dollar' +BitBag\SyliusCmsPlugin\Entity\SectionTranslation: + section1_translation: + name: 'translation1_name_en_US' + locale: 'en_US' + section2_translation: + name: 'translation2_name_en_US' + locale: 'en_US' + section3_translation: + name: 'translation3_name_en_US' + locale: 'en_US' +BitBag\SyliusCmsPlugin\Entity\Section: + section1: + code: 'section1-code' + translations: + - '@section1_translation' + section2: + code: 'section2-code' + translations: + - '@section2_translation' + section3: + code: 'section3-code' + translations: + - '@section3_translation' diff --git a/tests/Integration/Repository/BlockRepositoryTest.php b/tests/Integration/Repository/BlockRepositoryTest.php new file mode 100644 index 000000000..fb6c10718 --- /dev/null +++ b/tests/Integration/Repository/BlockRepositoryTest.php @@ -0,0 +1,71 @@ +loadFixturesFromFile('BlockRepositoryTest/test_it_finds_block_by_code.yml'); + + $blockRepository = $this->getRepository(); + + $block1 = $blockRepository->findEnabledByCode('block1-code', 'code'); + $block3 = $blockRepository->findEnabledByCode('block3-code', 'code'); + + self::assertNotNull($block1); + self::assertNull($block3); + } + + public function test_it_finds_enabled_block_by_section_code(): void + { + $this->loadFixturesFromFile('BlockRepositoryTest/test_it_finds_block_by_section_code.yml'); + + $blockRepository = $this->getRepository(); + + $block_array1 = $blockRepository->findBySectionCode('section1-code', 'en_US', 'code'); + $block_array3 = $blockRepository->findBySectionCode('section3-code', 'en_US', 'code'); + + self::assertNotEmpty($block_array1); + self::assertEmpty($block_array3); + } + + public function test_it_finds_enabled_block_by_product_code(): void + { + $this->loadFixturesFromFile('BlockRepositoryTest/test_it_finds_block_by_product_code.yml'); + + $blockRepository = $this->getRepository(); + + $block_array1 = $blockRepository->findByProductCode('MUG_SW', 'en_US', 'code'); + $block_array3 = $blockRepository->findByProductCode('MUG_SW3', 'en_US', 'code'); + + self::assertNotEmpty($block_array1); + self::assertEmpty($block_array3); + } + + private function getRepository(): BlockRepositoryInterface + { + /** @var BlockRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(BlockInterface::class); + + return $repository; + } +} diff --git a/tests/Integration/Repository/FrequentlyAskedQuestionRepositoryTest.php b/tests/Integration/Repository/FrequentlyAskedQuestionRepositoryTest.php new file mode 100644 index 000000000..0d5510187 --- /dev/null +++ b/tests/Integration/Repository/FrequentlyAskedQuestionRepositoryTest.php @@ -0,0 +1,73 @@ +loadFixturesFromFile('FrequentlyAskedQuestionRepositoryTest//test_it_finds_faq_by_position.yml'); + + $localeCode = 'en_US'; + $channelCode = 'code'; + + $faqRepository = $this->getRepository(); + + $faqs = $faqRepository->findEnabledOrderedByPosition($localeCode, $channelCode); + + self::assertNotEmpty($faqs); + self::assertCount(2, $faqs); + + $previousPosition = null; + foreach ($faqs as $faq) { + if (null !== $previousPosition) { + self::assertGreaterThanOrEqual($previousPosition, $faq->getPosition()); + self::assertTrue($faq->isEnabled()); + } + $previousPosition = $faq->getPosition(); + } + } + + public function test_it_finds_enabled_frequently_asked_question_by_code(): void + { + $this->loadFixturesFromFile('FrequentlyAskedQuestionRepositoryTest/test_it_finds_faq_by_code.yml'); + + $faq1Code = 'faq1-code'; + $faq3Code = 'faq3-code'; + + $faqRepository = $this->getRepository(); + + $faq1 = $faqRepository->findOneEnabledByCode($faq1Code); + $faq3 = $faqRepository->findOneEnabledByCode($faq3Code); + + self::assertNotNull($faq1); + self::assertEquals($faq1Code, $faq1->getCode()); + self::assertTrue($faq1->isEnabled()); + self::assertNull($faq3); + } + + private function getRepository(): FrequentlyAskedQuestionRepositoryInterface + { + /** @var FrequentlyAskedQuestionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(FrequentlyAskedQuestionInterface::class); + + return $repository; + } +} diff --git a/tests/Integration/Repository/MediaRepositoryTest.php b/tests/Integration/Repository/MediaRepositoryTest.php new file mode 100644 index 000000000..1e1e31498 --- /dev/null +++ b/tests/Integration/Repository/MediaRepositoryTest.php @@ -0,0 +1,71 @@ +loadFixturesFromFile('MediaRepositoryTest/test_it_finds_media_by_code.yml'); + + $mediaRepository = $this->getRepository(); + + $media1 = $mediaRepository->findOneEnabledByCode('media1-code', 'en_US', 'code'); + $media3 = $mediaRepository->findOneEnabledByCode('media3-code', 'en_US', 'code'); + + self::assertNotNull($media1); + self::assertNull($media3); + } + + public function test_it_finds_enabled_media_by_section_code(): void + { + $this->loadFixturesFromFile('MediaRepositoryTest/test_it_finds_media_by_section_code.yml'); + + $mediaRepository = $this->getRepository(); + + $media1 = $mediaRepository->findBySectionCode('section1-code', 'en_US', 'code'); + $media3 = $mediaRepository->findBySectionCode('section3-code', 'en_US', 'code'); + + self::assertNotEmpty($media1); + self::assertEmpty($media3); + } + + public function test_it_finds_enabled_media_by_product_code(): void + { + $this->loadFixturesFromFile('MediaRepositoryTest/test_it_finds_media_by_product_code.yml'); + + $mediaRepository = $this->getRepository(); + + $media1_array = $mediaRepository->findByProductCode('MUG_SW', 'en_US', 'code'); + $media3_array = $mediaRepository->findByProductCode('MUG_SW3', 'en_US', 'code'); + + self::assertNotEmpty($media1_array); + self::assertEmpty($media3_array); + } + + private function getRepository(): MediaRepositoryInterface + { + /** @var MediaRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(MediaInterface::class); + + return $repository; + } +} diff --git a/tests/Integration/Repository/PageRepositoryTest.php b/tests/Integration/Repository/PageRepositoryTest.php new file mode 100644 index 000000000..2a18ed8ff --- /dev/null +++ b/tests/Integration/Repository/PageRepositoryTest.php @@ -0,0 +1,115 @@ +loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_code.yml'); + + $pageRepository = $this->getRepository(); + + $page1_2_array = $pageRepository->findEnabled(true); + $page3_array = $pageRepository->findEnabled(false); + + self::assertCount(2, $page1_2_array); + self::assertCount(1, $page3_array); + } + + public function test_it_finds_enabled_page_by_code(): void + { + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_code.yml'); + + $pageRepository = $this->getRepository(); + + $page1 = $pageRepository->findOneEnabledByCode('page1-code', 'en_US'); + $page3 = $pageRepository->findOneEnabledByCode('page3-code', 'en_US'); + + self::assertNotNull($page1); + self::assertNull($page3); + } + + public function test_it_finds_enabled_page_by_section_code(): void + { + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_section_code.yml'); + + $pageRepository = $this->getRepository(); + + $page1_array = $pageRepository->findBySectionCode('section1-code', 'en_US'); + $page3_array = $pageRepository->findBySectionCode('section3-code', 'en_US'); + + self::assertNotEmpty($page1_array); + self::assertEmpty($page3_array); + } + + public function test_it_finds_enabled_page_by_product(): void + { + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_product.yml'); + + $pageRepository = $this->getRepository(); + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->getEntityManager()->getRepository(Product::class); + + /** @var Product $product1 */ + $product1 = $productRepository->findOneByCode('MUG_SW'); + /** @var Product $product3 */ + $product3 = $productRepository->findOneByCode('MUG_SW3'); + + $page1_array = $pageRepository->findByProduct($product1, 'code', null); + $page3_array = $pageRepository->findByProduct($product3, 'code', null); + + self::assertNotEmpty($page1_array); + self::assertEmpty($page3_array); + } + + public function test_it_finds_enabled_page_by_product_and_section_code(): void + { + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml'); + + $pageRepository = $this->getRepository(); + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->getEntityManager()->getRepository(Product::class); + + /** @var Product $product1 */ + $product1 = $productRepository->findOneByCode('MUG_SW'); + /** @var Product $product3 */ + $product3 = $productRepository->findOneByCode('MUG_SW3'); + + $page1_array = $pageRepository->findByProductAndSectionCode($product1, 'section1-code', 'code', null); + $page3_array = $pageRepository->findByProductAndSectionCode($product3, 'section3-code', 'code', null); + + self::assertNotEmpty($page1_array); + self::assertEmpty($page3_array); + } + + private function getRepository(): PageRepositoryInterface + { + /** @var PageRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(PageInterface::class); + + return $repository; + } +} diff --git a/tests/Integration/Repository/SectionRepositoryTest.php b/tests/Integration/Repository/SectionRepositoryTest.php new file mode 100644 index 000000000..446290dd4 --- /dev/null +++ b/tests/Integration/Repository/SectionRepositoryTest.php @@ -0,0 +1,85 @@ +getRepository(); + + $localeCode = 'en_US'; + $queryBuilder = $repository->createListQueryBuilder($localeCode); + + self::assertInstanceOf(QueryBuilder::class, $queryBuilder); + self::assertNotNull($queryBuilder->getQuery()); + } + + public function test_it_finds_section_by_name_part(): void + { + $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_name.yml'); + + $repository = $this->getRepository(); + + $phrase = 'translation'; + $locale = 'en_US'; + $sections = $repository->findByNamePart($phrase, $locale); + + self::assertIsArray($sections); + self::assertCount(3, $sections); + } + + public function test_it_finds_one_by_code(): void + { + $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_code.yml'); + + $repository = $this->getRepository(); + + $code = 'section1-code'; + $localeCode = 'en_US'; + $section = $repository->findOneByCode($code, $localeCode); + + self::assertInstanceOf(SectionInterface::class, $section); + } + + public function test_it_finds_by_codes_and_locale(): void + { + $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml'); + + $repository = $this->getRepository(); + + $codes = 'section1-code,section2-code'; + $localeCode = 'en_US'; + $sections = $repository->findByCodesAndLocale($codes, $localeCode); + + self::assertIsArray($sections); + self::assertCount(2, $sections); + } + + private function getRepository(): SectionRepositoryInterface + { + /** @var SectionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(SectionInterface::class); + + return $repository; + } +} diff --git a/tests/Responses/Expected/show_sitemap_pages.xml b/tests/Responses/Expected/show_sitemap_pages.xml deleted file mode 100644 index ca7e5342d..000000000 --- a/tests/Responses/Expected/show_sitemap_pages.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - http://localhost/en_US/page/test - @string@.isDateTime() - daily - 0.7 - - - http://localhost/en_US/page/mock - @string@.isDateTime() - daily - 0.7 - - diff --git a/tests/Responses/Expected/show_sitemap_pages_locale.xml b/tests/Responses/Expected/show_sitemap_pages_locale.xml deleted file mode 100644 index 0c4855759..000000000 --- a/tests/Responses/Expected/show_sitemap_pages_locale.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - http://localhost/en_US/page/test - - - @string@.isDateTime() - daily - 0.7 - - - http://localhost/nl_NL/page/test-nl - - - @string@.isDateTime() - daily - 0.7 - - - http://localhost/en_US/page/mock - - - @string@.isDateTime() - daily - 0.7 - - - http://localhost/nl_NL/page/mock-nl - - - @string@.isDateTime() - daily - 0.7 - - diff --git a/tests/Responses/Expected/show_sitemap_sections.xml b/tests/Responses/Expected/show_sitemap_sections.xml deleted file mode 100644 index 9bffc1cbc..000000000 --- a/tests/Responses/Expected/show_sitemap_sections.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - http://localhost/en_US/section/test - daily - 0.7 - - - http://localhost/en_US/section/mock - daily - 0.7 - - diff --git a/tests/Responses/Expected/show_sitemap_sections_locale.xml b/tests/Responses/Expected/show_sitemap_sections_locale.xml deleted file mode 100644 index ba9c3e7d8..000000000 --- a/tests/Responses/Expected/show_sitemap_sections_locale.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - http://localhost/en_US/section/test - - - daily - 0.7 - - - http://localhost/nl_NL/section/test - - - daily - 0.7 - - - http://localhost/en_US/section/mock - - - daily - 0.7 - - - http://localhost/nl_NL/section/mock - - - daily - 0.7 - -