Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-438: Code cleanup #520

Merged
merged 9 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/Assigner/ChannelsAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function it_assigns_channels(
ChannelRepositoryInterface $channelRepository,
ChannelInterface $webChannel,
ChannelInterface $posChannel,
ChannelsAwareInterface $channelsAware
ChannelsAwareInterface $channelsAware,
): void {
$channelRepository->findOneBy(['code' => 'web'])->willReturn($webChannel);
$channelRepository->findOneBy(['code' => 'pos'])->willReturn($posChannel);
Expand Down
5 changes: 2 additions & 3 deletions spec/Assigner/CollectionsAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public function it_assigns_collections(
CollectionRepositoryInterface $collectionRepository,
CollectionInterface $aboutCollection,
CollectionInterface $blogCollection,
CollectibleInterface $collectionsAware
): void
{
CollectibleInterface $collectionsAware,
): void {
$collectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutCollection);
$collectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogCollection);

Expand Down
2 changes: 1 addition & 1 deletion spec/Assigner/LocalesAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function it_assigns_locales_to_locale_aware_entity(
RepositoryInterface $localeRepository,
LocaleAwareInterface $localesAware,
LocaleInterface $locale1,
LocaleInterface $locale2
LocaleInterface $locale2,
) {
$locale1->getCode()->willReturn('en_US');
$locale2->getCode()->willReturn('fr_FR');
Expand Down
2 changes: 1 addition & 1 deletion spec/Assigner/ProductsAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function it_assigns_products(
ProductRepositoryInterface $productRepository,
ProductInterface $mugProduct,
ProductInterface $tshirtProduct,
ProductsAwareInterface $productsAware
ProductsAwareInterface $productsAware,
): void {
$productRepository->findOneBy(['code' => 'mug'])->willReturn($mugProduct);
$productRepository->findOneBy(['code' => 't-shirt'])->willReturn($tshirtProduct);
Expand Down
2 changes: 1 addition & 1 deletion spec/Assigner/ProductsInTaxonsAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function it_assigns_taxons_to_products_in_taxons_aware_entity(
TaxonRepositoryInterface $taxonRepository,
ProductsInTaxonsAwareInterface $productsInTaxonsAware,
TaxonInterface $taxon1,
TaxonInterface $taxon2
TaxonInterface $taxon2,
) {
$taxon1->getCode()->willReturn('taxon_code_1');
$taxon2->getCode()->willReturn('taxon_code_2');
Expand Down
2 changes: 1 addition & 1 deletion spec/Assigner/TaxonsAssignerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function it_assigns_taxons(
TaxonRepositoryInterface $taxonRepository,
TaxonInterface $mugsTaxon,
TaxonInterface $stickersTaxon,
TaxonAwareInterface $taxonsAware
TaxonAwareInterface $taxonsAware,
): void {
$taxonRepository->findOneBy(['code' => 'mugs'])->willReturn($mugsTaxon);
$taxonRepository->findOneBy(['code' => 'stickers'])->willReturn($stickersTaxon);
Expand Down
4 changes: 2 additions & 2 deletions spec/Controller/Action/Admin/UploadEditorImageActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class UploadEditorImageActionSpec extends ObjectBehavior
public function let(
MediaProviderResolverInterface $mediaProviderResolver,
MediaRepositoryInterface $mediaRepository,
FactoryInterface $mediaFactory
FactoryInterface $mediaFactory,
) {
$this->beConstructedWith($mediaProviderResolver, $mediaRepository, $mediaFactory);
}
Expand All @@ -43,7 +43,7 @@ public function it_uploads_media(
FileBag $fileBag,
MediaProviderResolverInterface $mediaProviderResolver,
ProviderInterface $provider,
MediaRepositoryInterface $mediaRepository
MediaRepositoryInterface $mediaRepository,
): void {
$uploadedFile = new UploadedFile(__DIR__ . '/../../../../tests/Behat/Resources/images/aston_martin_db_11.jpg', 'aston_martin_db_11.jpg');

Expand Down
2 changes: 0 additions & 2 deletions spec/Entity/BlockSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Resource\Model\ResourceInterface;

final class BlockSpec extends ObjectBehavior
Expand Down
3 changes: 1 addition & 2 deletions spec/Entity/MediaSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

namespace spec\BitBag\SyliusCmsPlugin\Entity;

use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use BitBag\SyliusCmsPlugin\Entity\Media;
use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;

Expand Down
3 changes: 1 addition & 2 deletions spec/Entity/PageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

namespace spec\BitBag\SyliusCmsPlugin\Entity;

use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use BitBag\SyliusCmsPlugin\Entity\Page;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Resource\Model\ResourceInterface;

final class PageSpec extends ObjectBehavior
Expand Down
4 changes: 2 additions & 2 deletions spec/EventListener/MediaUploadListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function it_is_initializable(): void
public function it_does_not_upload_if_not_media_instance(
ResourceControllerEvent $event,
MediaInterface $media,
MediaProviderResolverInterface $mediaProviderResolver
MediaProviderResolverInterface $mediaProviderResolver,
): void {
$event->getSubject()->willReturn(Argument::any());

Expand All @@ -44,7 +44,7 @@ public function it_uploads_media(
ResourceControllerEvent $event,
MediaInterface $media,
MediaProviderResolverInterface $mediaProviderResolver,
ProviderInterface $provider
ProviderInterface $provider,
): void {
$event->getSubject()->willReturn($media);
$mediaProviderResolver->resolveProvider($media)->willReturn($provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public function it_transforms_empty_array_to_empty_collection(): void
public function it_transforms_non_empty_array_to_collection(
MediaRepositoryInterface $mediaRepository,
MediaInterface $media1,
MediaInterface $media2
): void
{
MediaInterface $media2,
): void {
$mediaCodes = ['code1', 'code2'];
$mediaRepository->findBy(['code' => $mediaCodes])->willReturn([$media1, $media2]);

Expand All @@ -63,9 +62,8 @@ public function it_reverse_transforms_empty_collection_to_empty_array(): void

public function it_reverse_transforms_collection_to_array_of_media_codes(
MediaInterface $media1,
MediaInterface $media2
): void
{
MediaInterface $media2,
): void {
$media1->getCode()->willReturn('code1');
$media2->getCode()->willReturn('code2');

Expand Down
24 changes: 11 additions & 13 deletions spec/Importer/BlockImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
use BitBag\SyliusCmsPlugin\Importer\BlockImporter;
use BitBag\SyliusCmsPlugin\Importer\BlockImporterInterface;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterLocalesResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsInTaxonsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterTaxonsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterChannelsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterLocalesResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterProductsInTaxonsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterProductsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterTaxonsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Validator\ConstraintViolationList;
Expand All @@ -36,9 +36,8 @@ public function let(
ImporterTaxonsResolverInterface $importerTaxonsResolver,
ImporterProductsInTaxonsResolverInterface $importerProductsInTaxonsResolver,
ValidatorInterface $validator,
BlockRepositoryInterface $blockRepository
)
{
BlockRepositoryInterface $blockRepository,
) {
$this->beConstructedWith(
$blockResourceResolver,
$importerCollectionsResolver,
Expand All @@ -48,7 +47,7 @@ public function let(
$importerTaxonsResolver,
$importerProductsInTaxonsResolver,
$validator,
$blockRepository
$blockRepository,
);
}

Expand All @@ -68,9 +67,8 @@ public function it_imports_block(
ImporterProductsInTaxonsResolverInterface $importerProductsInTaxonsResolver,
ValidatorInterface $validator,
BlockRepositoryInterface $blockRepository,
BlockInterface $block
)
{
BlockInterface $block,
) {
$row = ['name' => 'block_name', 'code' => 'block_code', 'enabled' => '1'];

$blockResourceResolver->getResource('block_code')->willReturn($block);
Expand Down
10 changes: 4 additions & 6 deletions spec/Importer/MediaImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Locale\Context\LocaleContextInterface;
Expand All @@ -27,7 +26,7 @@ public function let(
LocaleContextInterface $localeContext,
ImporterCollectionsResolverInterface $importerCollectionsResolver,
ValidatorInterface $validator,
MediaRepositoryInterface $mediaRepository
MediaRepositoryInterface $mediaRepository,
) {
$this->beConstructedWith(
$mediaResourceResolver,
Expand All @@ -50,9 +49,8 @@ public function it_imports_media(
ImporterCollectionsResolverInterface $importerCollectionsResolver,
ValidatorInterface $validator,
MediaRepositoryInterface $mediaRepository,
MediaInterface $media
)
{
MediaInterface $media,
) {
$row = ['name_pl' => 'name', 'content_pl' => 'content', 'alt_pl' => 'alt', 'code' => 'media_code'];

$mediaResourceResolver->getResource('media_code')->willReturn($media);
Expand Down
13 changes: 4 additions & 9 deletions spec/Importer/PageImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@

namespace spec\BitBag\SyliusCmsPlugin\Importer;

use BitBag\SyliusCmsPlugin\Downloader\ImageDownloaderInterface;
use BitBag\SyliusCmsPlugin\Entity\PageInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\MediaProviderResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterChannelsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\Importer\ImporterCollectionsResolverInterface;
use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface;
use Doctrine\ORM\EntityManagerInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Locale\Context\LocaleContextInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validator\ValidatorInterface;

Expand All @@ -32,7 +28,7 @@ public function let(
ImporterCollectionsResolverInterface $importerCollectionsResolver,
ImporterChannelsResolverInterface $importerChannelsResolver,
ValidatorInterface $validator,
EntityManagerInterface $entityManager
EntityManagerInterface $entityManager,
) {
$this->beConstructedWith(
$pageResourceResolver,
Expand All @@ -58,8 +54,7 @@ public function it_imports_page_no_url(
ValidatorInterface $validator,
EntityManagerInterface $entityManager,
PageInterface $page,
)
{
) {
$row = [
'code' => 'page_code',
'name' => 'page_name',
Expand Down
2 changes: 1 addition & 1 deletion spec/MediaProvider/GenericProviderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class GenericProviderSpec extends ObjectBehavior
{
public function let(
MediaUploaderInterface $uploader,
Environment $twigEngine
Environment $twigEngine,
) {
$this->beConstructedWith($uploader, $twigEngine, '@Template', '/media/');
}
Expand Down
2 changes: 1 addition & 1 deletion spec/Menu/ContentManagementMenuBuilderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function it_is_initializable(): void
public function it_build_menu(
MenuBuilderEvent $menuBuilderEvent,
ItemInterface $menu,
ItemInterface $cmsRootMenuItem
ItemInterface $cmsRootMenuItem,
): void {
$menuBuilderEvent->getMenu()->willReturn($menu);
$menu->addChild('bitbag_cms')->willReturn($cmsRootMenuItem);
Expand Down
30 changes: 13 additions & 17 deletions spec/Menu/MenuReorderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@ public function it_reorders_menu_items(
ItemInterface $menu,
ItemInterface $item1,
ItemInterface $item2,
ItemInterface $item3
): void
{
ItemInterface $item3,
): void {
$menu->getChildren()->willReturn([
'item1' => $item1,
'item2' => $item2,
'item3' => $item3
'item3' => $item3,
]);

$menu->getChild('item2')->willReturn($item2);

$menu->setChildren([
'item1' => $item1,
'item3' => $item3,
'item2' => $item2
'item2' => $item2,
])->shouldBeCalled();

$this->reorder($menu, 'item2', 'item3');
Expand All @@ -55,12 +54,11 @@ public function it_reorders_menu_items(
public function it_does_not_reorder_if_new_item_is_not_found(
ItemInterface $menu,
ItemInterface $item1,
ItemInterface $item3
): void
{
ItemInterface $item3,
): void {
$menu->getChildren()->willReturn([
'item1' => $item1,
'item3' => $item3
'item3' => $item3,
]);

$menu->getChild('item2')->willReturn(null);
Expand All @@ -72,12 +70,11 @@ public function it_does_not_reorder_if_new_item_is_not_found(
public function it_does_not_reorder_if_target_item_is_not_found(
ItemInterface $menu,
ItemInterface $item1,
ItemInterface $item2
): void
{
ItemInterface $item2,
): void {
$menu->getChildren()->willReturn([
'item1' => $item1,
'item2' => $item2
'item2' => $item2,
]);

$menu->getChild('item1')->willReturn($item1);
Expand All @@ -89,12 +86,11 @@ public function it_does_not_reorder_if_target_item_is_not_found(
public function it_does_not_modify_menu_when_no_reorder_is_needed(
ItemInterface $menu,
ItemInterface $item1,
ItemInterface $item2
): void
{
ItemInterface $item2,
): void {
$menu->getChildren()->willReturn([
'item1' => $item1,
'item2' => $item2
'item2' => $item2,
]);

$menu->getChild('item1')->willReturn($item1);
Expand Down
6 changes: 3 additions & 3 deletions spec/Processor/ImportProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ImportProcessorSpec extends ObjectBehavior
public function let(
ImporterChainInterface $importerChain,
ReaderInterface $reader,
EntityManagerInterface $entityManager
EntityManagerInterface $entityManager,
) {
$this->beConstructedWith($importerChain, $reader, $entityManager);
}
Expand All @@ -38,7 +38,7 @@ public function it_processes_import_data(
ImporterChainInterface $importerChain,
ReaderInterface $reader,
EntityManagerInterface $entityManager,
ImporterInterface $importer
ImporterInterface $importer,
) {
$resourceCode = 'some_resource';
$filePath = 'path/to/file.csv';
Expand All @@ -65,7 +65,7 @@ public function it_throws_exception_when_import_fails(
ImporterChainInterface $importerChain,
ReaderInterface $reader,
EntityManagerInterface $entityManager,
ImporterInterface $importer
ImporterInterface $importer,
) {
$resourceCode = 'some_resource';
$filePath = 'path/to/file.csv';
Expand Down
Loading
Loading