From 370de391b9c80ef6e4fbb171f30b7d97a524ad8a Mon Sep 17 00:00:00 2001 From: Willy Date: Tue, 24 Sep 2019 11:30:40 +0200 Subject: [PATCH 01/24] API-693: Init phpsepc --- .gitignore | 8 ++++++++ .phpspec.yml | 7 +++++++ composer.json | 6 ++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .phpspec.yml diff --git a/.gitignore b/.gitignore index db2b67b..59fb681 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,17 @@ /public/ /var/ /vendor/ +/bin/ +/composer.lock +/symfony.lock ###< symfony/framework-bundle ### .idea/ ###> docker ### docker-compose.override.yml ###< docker ### + +###> friendsofphp/php-cs-fixer ### +/.php_cs +/.php_cs.cache +###< friendsofphp/php-cs-fixer ### diff --git a/.phpspec.yml b/.phpspec.yml new file mode 100644 index 0000000..b0471b1 --- /dev/null +++ b/.phpspec.yml @@ -0,0 +1,7 @@ +suites: + dam-connector: + namespace: AkeneoDAMConnector + psr4_prefix: AkeneoDAMConnector + spec_path: tests/ + spec_prefix: Specification + src_path: src/ diff --git a/composer.json b/composer.json index 0917e98..ee481be 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "symfony/yaml": "4.3.*" }, "require-dev": { - "akeneo/php-coupling-detector": "0.3.*" + "akeneo/php-coupling-detector": "0.3.*", + "phpspec/phpspec": "^4.0" }, "repositories": [ { @@ -37,7 +38,8 @@ "preferred-install": { "*": "dist" }, - "sort-packages": true + "sort-packages": true, + "bin-dir": "bin" }, "autoload": { "psr-4": { From 4297649c06c7323c5e91699308eff74b1865d20c Mon Sep 17 00:00:00 2001 From: Willy Date: Tue, 24 Sep 2019 16:35:31 +0200 Subject: [PATCH 02/24] API-693: Spec SynchronizeAssets --- .../Service/SynchronizeAssetsSpec.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/Specification/Application/Service/SynchronizeAssetsSpec.php diff --git a/tests/Specification/Application/Service/SynchronizeAssetsSpec.php b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php new file mode 100644 index 0000000..766e6f7 --- /dev/null +++ b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php @@ -0,0 +1,57 @@ +beConstructedWith($fetchAssets, $assetTransformer, $assetApi); + } + + function it_is_initializable() + { + $this->shouldHaveType(SynchronizeAssets::class); + } + + function it_synchronizes_assets( + $fetchAssets, + $assetTransformer, + $assetApi, + DamAsset $damTable, + DamAsset $damMug, + PimAsset $pimTable, + PimAsset $pimMug, + \Iterator $damAssets, + AssetFamilyCode $assetFamilyCode + ) { + $damAssets->rewind()->shouldBeCalled(); + $damAssets->valid()->willReturn(true, true, false); + $damAssets->current()->willReturn($damTable, $damMug); + $damAssets->next()->shouldBeCalled(); + + $fetchAssets->fetch($assetFamilyCode, null)->willReturn($damAssets); + $assetTransformer->damToPim($damTable)->willReturn($pimTable); + $assetTransformer->damToPim($damMug)->willReturn($pimMug); + + $assetApi->upsert($assetFamilyCode, $pimTable)->shouldBeCalled(); + $assetApi->upsert($assetFamilyCode, $pimMug)->shouldBeCalled(); + $assetApi->flush($assetFamilyCode)->shouldBeCalled(); + + $this->execute($assetFamilyCode, null); + } +} From ea2ac638e378f0cb34462f7dc70f0481261dd3bb Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 10:38:27 +0200 Subject: [PATCH 03/24] API-693: Synchronize assets structure spec --- .../Service/SynchronizeAssetsStructure.php | 1 - .../SynchronizeAssetsStructureSpec.php | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 tests/Specification/Application/Service/SynchronizeAssetsStructureSpec.php diff --git a/src/Application/Service/SynchronizeAssetsStructure.php b/src/Application/Service/SynchronizeAssetsStructure.php index 128caa5..829d057 100644 --- a/src/Application/Service/SynchronizeAssetsStructure.php +++ b/src/Application/Service/SynchronizeAssetsStructure.php @@ -34,7 +34,6 @@ public function execute() { $structureConfig = $this->structureConfigLoader->load(); foreach ($structureConfig as $assetFamilyCode => $assetFamilyConfig) { - echo "Creating family: ". $assetFamilyCode ."\n"; $assetFamilyData = [ 'code' => $assetFamilyCode, ]; diff --git a/tests/Specification/Application/Service/SynchronizeAssetsStructureSpec.php b/tests/Specification/Application/Service/SynchronizeAssetsStructureSpec.php new file mode 100644 index 0000000..4bcf9e7 --- /dev/null +++ b/tests/Specification/Application/Service/SynchronizeAssetsStructureSpec.php @@ -0,0 +1,115 @@ +beConstructedWith($structureConfigLoader, $updateAssetStructure); + } + + function it_is_initializable() + { + $this->shouldHaveType(SynchronizeAssetsStructure::class); + } + + function it_synchronizes_assets_structure( + $structureConfigLoader, + $updateAssetStructure + ) { + $config = $this->getConfig(); + $structureConfigLoader->load()->willReturn($config); + + $packshotData = [ + 'code' => 'packshot', + 'product_link_rules' => [ + [ + 'product_selections' => [ + 'field' => 'sku', + 'operator' => 'EQUALS', + 'value' => '{{product_ref}}', + ], + ] + ] + ]; + $userInstructionData = [ + 'code' => 'user_instruction', + 'product_link_rules' => [ + [ + 'product_selections' => [ + 'field' => 'sku', + 'operator' => 'EQUALS', + 'value' => '{{product_ref}}', + ], + ] + ] + ]; + + $updateAssetStructure->upsertFamily('packshot', ['code' => 'packshot'])->shouldBeCalled(); + $updateAssetStructure->upsertFamily('packshot', $packshotData)->shouldBeCalled(); + + $updateAssetStructure->upsertFamily('user_instruction', ['code' => 'user_instruction'])->shouldBeCalled(); + $updateAssetStructure->upsertFamily('user_instruction', $userInstructionData)->shouldBeCalled(); + + $updateAssetStructure->upsertAttribute('packshot', 'locale', ['code' => 'locale', 'type' => 'text'])->shouldBeCalled(); + $updateAssetStructure->upsertAttribute('packshot', 'product_ref', ['code' => 'product_ref', 'type' => 'text'])->shouldBeCalled(); + + $updateAssetStructure->upsertAttribute('user_instruction', 'locale', ['code' => 'locale', 'type' => 'text'])->shouldBeCalled(); + $updateAssetStructure->upsertAttribute('user_instruction', 'product_ref', ['code' => 'product_ref', 'type' => 'text'])->shouldBeCalled(); + + $this->execute(); + } + + private function getConfig(): array + { + return [ + 'packshot' => [ + 'product_link_rules' => [ + 'product_selections' => [ + 'field' => 'sku', + 'operator' => 'EQUALS', + 'value' => '{{product_ref}}', + ], + ], + 'attributes' => [ + [ + 'code' => 'locale', + 'type' => 'text' + ], + [ + 'code' => 'product_ref', + 'type' => 'text' + ], + ], + ], + 'user_instruction' => [ + 'product_link_rules' => [ + 'product_selections' => [ + 'field' => 'sku', + 'operator' => 'EQUALS', + 'value' => '{{product_ref}}', + ], + ], + 'attributes' => [ + [ + 'code' => 'locale', + 'type' => 'text' + ], + [ + 'code' => 'product_ref', + 'type' => 'text' + ], + ], + ], + ]; + } +} From 100a18ac0e1ae78771c2f80d4855d0c7c420d235 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 10:55:34 +0200 Subject: [PATCH 04/24] API-693: Attribute builder spec --- .../Mapping/AssetAttributeBuilderSpec.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php diff --git a/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php new file mode 100644 index 0000000..75e485b --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php @@ -0,0 +1,70 @@ +beConstructedWith($structureConfigLoader); + } + + function it_is_initializable(): void + { + $this->shouldHaveType(AssetAttributeBuilder::class); + } + + function it_builds_an_attribute( + $structureConfigLoader, + AssetFamilyCode $familyCode, + AssetAttributeCode $attributeCode + ): void { + $structureConfigLoader->load()->willReturn($this->getConfig()); + + $familyCode->__toString()->willReturn('packshot'); + $attributeCode->__toString()->willReturn('locale'); + + $attribute = $this->build($familyCode, $attributeCode); + $attribute->getCode()->shouldReturn($attributeCode); + $attribute->getType()->shouldReturn('text'); + $attribute->isLocalizable()->shouldReturn(false); + } + + function it_throws_an_exception_if_attribute_does_not_exist( + $structureConfigLoader, + AssetFamilyCode $familyCode, + AssetAttributeCode $attributeCode + ): void { + $structureConfigLoader->load()->willReturn($this->getConfig()); + + $familyCode->__toString()->willReturn('packshot'); + $attributeCode->__toString()->willReturn('description'); + + $this + ->shouldThrow( + new \RuntimeException() + ) + ->during('build', [$familyCode, $attributeCode]); + } + + private function getConfig(): array + { + return [ + 'packshot' => [ + 'attributes' => [ + [ + 'code' => 'locale', + 'type' => 'text' + ], + ], + ], + ]; + } +} From 543c2f678afe311a7c51d51baaddafdc482e8a45 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 12:11:54 +0200 Subject: [PATCH 05/24] API-693: Asset mapper spec --- .../Application/Mapping/AssetMapperSpec.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetMapperSpec.php diff --git a/tests/Specification/Application/Mapping/AssetMapperSpec.php b/tests/Specification/Application/Mapping/AssetMapperSpec.php new file mode 100644 index 0000000..b4fa7a9 --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetMapperSpec.php @@ -0,0 +1,91 @@ +beConstructedWith($mappingConfigLoader, $assetAttributeBuilder); + } + + public function it_provides_mapped_properties_of_a_family($mappingConfigLoader, AssetFamilyCode $familyCode) + { + $mappingConfigLoader->load()->willReturn($this->getMapping()); + $familyCode->__toString()->willReturn('packshot'); + + $this->getMappedProperties($familyCode)->shouldReturn(['sku', 'url', 'colors']); + } + + public function it_throws_an_exception_if_not_mapping_can_be_provided($mappingConfigLoader, AssetFamilyCode $familyCode) + { + $mappingConfigLoader->load()->willReturn($this->getMapping()); + $familyCode->__toString()->willReturn('family'); + + $this + ->shouldThrow( + new FamilyMappingNotFound() + ) + ->during('getMappedProperties', [$familyCode]); + } + + public function it_maps_a_dam_property_to_a_pim_attribute( + $mappingConfigLoader, + $assetAttributeBuilder, + AssetFamilyCode $familyCode, + AssetAttribute $attribute + ) { + $mappingConfigLoader->load()->willReturn($this->getMapping()); + $familyCode->__toString()->willReturn('packshot'); + $assetAttributeBuilder + ->build('packshot', Argument::that(function ($argument) { + return $argument instanceof AssetAttributeCode && + 'preview' === $argument->__toString(); + })) + ->shouldBeCalled() + ->willReturn($attribute); + + $this->mapAttribute($familyCode, 'url')->shouldReturn($attribute); + } + + public function it_throws_an_exception_if_the_dam_property_does_not_match_a_pim_attribute( + $mappingConfigLoader, + AssetFamilyCode $familyCode + ) { + $mappingConfigLoader->load()->willReturn($this->getMapping()); + $familyCode->__toString()->willReturn('packshot'); + + $this + ->shouldThrow( + new AttributeMappingNotFound() + ) + ->during('mapAttribute', [$familyCode, 'roustifouette']); + } + + private function getMapping(): array + { + return [ + 'packshot' => [ + 'sku' => 'product_ref', + 'url' => 'preview', + 'colors' => 'main_colors', + ], + 'user_instruction' => [ + 'sku' => 'product_ref', + 'url' => 'media_link', + 'pages' => 'number_of_pages', + ], + ]; + } +} From b7d87049701d76b0f2a50a0a4cdb222449153f4e Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:00:28 +0200 Subject: [PATCH 06/24] API-693: Asset transformer spec --- .../Mapping/AssetTransformerSpec.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetTransformerSpec.php diff --git a/tests/Specification/Application/Mapping/AssetTransformerSpec.php b/tests/Specification/Application/Mapping/AssetTransformerSpec.php new file mode 100644 index 0000000..16917f2 --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetTransformerSpec.php @@ -0,0 +1,67 @@ +beConstructedWith($assetMapper, $assetConverter); + } + + public function it_transforms_a_dam_asset_to_pim_asset( + $assetMapper, + $assetConverter, + DamAsset $damAsset, + AssetFamilyCode $familyCode, + DamAssetValue $skuValue, + DamAssetValue $colorsValue, + DamAssetValue $designedByValue, + DamAssetIdentifier $damIdentifier, + AssetAttribute $skuAttribute, + AssetAttribute $colorsAttribute, + PimAssetValue $skuPimValue, + PimAssetValue $colorsPimValue + ): void { + $mappedProperties = ['sku', 'colors', 'url']; + $damValues = [ + 'sku' => $skuValue, + 'colors' => $colorsValue, + 'designed_by' => $designedByValue, + ]; + $damAsset->assetFamilyCode()->willReturn($familyCode); + $damAsset->getValues()->willReturn($damValues); + $damAsset->damAssetIdentifier()->willReturn($damIdentifier); + + $damIdentifier->__toString()->willReturn('dam_identifier'); + + $assetMapper->getMappedProperties($familyCode)->willReturn($mappedProperties); + $assetMapper->mapAttribute($familyCode, 'sku')->willReturn($skuAttribute); + $assetMapper->mapAttribute($familyCode, 'colors')->willReturn($colorsAttribute); + $assetMapper->mapAttribute($familyCode, 'designed_by')->shouldNotBeCalled(); + + $assetConverter->convert($damAsset, $skuValue, $skuAttribute)->shouldBeCalled()->willReturn($skuPimValue); + $assetConverter->convert($damAsset, $designedByValue, Argument::any())->shouldNotBeCalled(); + $assetConverter + ->convert($damAsset, $colorsValue, $colorsAttribute) + ->shouldBeCalled() + ->willReturn($colorsPimValue); + + $pimAsset = $this->damToPim($damAsset); + $pimAsset->getCode()->shouldReturn('dam_identifier'); + } +} From ca8bdde17e690835357432cd01f030e4ede5e6ab Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:12:30 +0200 Subject: [PATCH 07/24] API-693: Media link converter spec --- src/Domain/Asset/PimAssetValue.php | 6 +- .../MediaLinkConverterSpec.php | 61 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php diff --git a/src/Domain/Asset/PimAssetValue.php b/src/Domain/Asset/PimAssetValue.php index 788b73a..2b4417c 100644 --- a/src/Domain/Asset/PimAssetValue.php +++ b/src/Domain/Asset/PimAssetValue.php @@ -17,7 +17,7 @@ class PimAssetValue private $channel; - public function __construct(AssetAttribute $attribute, $data, string $locale = null, string $channel = null) + public function __construct(AssetAttribute $attribute, $data, ?string $locale = null, ?string $channel = null) { $this->attribute = $attribute; $this->data = $data; @@ -43,12 +43,12 @@ public function getData() return $this->data; } - public function getLocale(): string + public function getLocale(): ?string { return $this->locale; } - public function getChannel(): string + public function getChannel(): ?string { return $this->channel; } diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php new file mode 100644 index 0000000..87a0c86 --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php @@ -0,0 +1,61 @@ +shouldHaveType(MediaLinkConverter::class); + $this->shouldImplement(AssetValueConverter::class); + } + + public function it_provides_a_supported_type(): void + { + $this->getSupportedType()->shouldReturn('media_link'); + } + + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute, + Locale $locale + ): void { + $attribute->isLocalizable()->willReturn(true); + $damAsset->locale()->willReturn($locale); + $locale->__toString()->willReturn('en_US'); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn('en_US'); + $pimValue->getChannel()->shouldReturn(null); + } + + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute + ): void { + $attribute->isLocalizable()->willReturn(false); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn(null); + $pimValue->getChannel()->shouldReturn(null); + } +} From 324f537d786ce58b3658859da619eed1fe34d3ce Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:20:43 +0200 Subject: [PATCH 08/24] API-693: Multi option converter spec --- .../MultiOptionConverterSpec.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php new file mode 100644 index 0000000..a6d7c46 --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php @@ -0,0 +1,60 @@ +shouldHaveType(MultiOptionConverter::class); + $this->shouldImplement(AssetValueConverter::class); + } + + public function it_provides_a_supported_type(): void + { + $this->getSupportedType()->shouldReturn('multiple_options'); + } + + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute, + Locale $locale + ): void { + $damAssetValue->value()->willReturn('blue, yellow, brown'); + $attribute->isLocalizable()->willReturn(true); + $damAsset->locale()->willReturn($locale); + $locale->__toString()->willReturn('en_US'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn(['blue', 'yellow', 'brown']); + $pimValue->getLocale()->shouldReturn('en_US'); + $pimValue->getChannel()->shouldReturn(null); + } + + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute + ): void { + $damAssetValue->value()->willReturn('blue, yellow, brown'); + $attribute->isLocalizable()->willReturn(false); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn(['blue', 'yellow', 'brown']); + $pimValue->getLocale()->shouldReturn(null); + $pimValue->getChannel()->shouldReturn(null); + } +} From 8e03a36bc014247a7e2ff1c541fdeb0426895f58 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:25:22 +0200 Subject: [PATCH 09/24] API-693: Single option spec --- .../SingleOptionConverterSpec.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php new file mode 100644 index 0000000..dd75d7e --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php @@ -0,0 +1,61 @@ +shouldHaveType(SingleOptionConverter::class); + $this->shouldImplement(AssetValueConverter::class); + } + + public function it_provides_a_supported_type(): void + { + $this->getSupportedType()->shouldReturn('single_option'); + } + + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute, + Locale $locale + ): void { + $attribute->isLocalizable()->willReturn(true); + $damAsset->locale()->willReturn($locale); + $locale->__toString()->willReturn('en_US'); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn('en_US'); + $pimValue->getChannel()->shouldReturn(null); + } + + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute + ): void { + $attribute->isLocalizable()->willReturn(false); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn(null); + $pimValue->getChannel()->shouldReturn(null); + } +} From daa4bdb158045c91b160f5b4f270d92db91114a2 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:33:23 +0200 Subject: [PATCH 10/24] API-693: Fix use in MultiOptionConverter --- .../Mapping/AssetValueConverter/MultiOptionConverter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php b/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php index 26e8182..fc8d526 100644 --- a/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php +++ b/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php @@ -9,7 +9,6 @@ use AkeneoDAMConnector\Domain\Asset\DamAssetValue; use AkeneoDAMConnector\Domain\Asset\PimAssetValue; use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\AssetAttributeCode; class MultiOptionConverter implements AssetValueConverter { From b9d23e5964a959aae0207f82b2c9fe573c2dc021 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 15:35:15 +0200 Subject: [PATCH 11/24] API-693: Text converter spec --- .../AssetValueConverter/TextConverterSpec.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php new file mode 100644 index 0000000..ccb66c3 --- /dev/null +++ b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php @@ -0,0 +1,61 @@ +shouldHaveType(TextConverter::class); + $this->shouldImplement(AssetValueConverter::class); + } + + public function it_provides_a_supported_type(): void + { + $this->getSupportedType()->shouldReturn('text'); + } + + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute, + Locale $locale + ): void { + $attribute->isLocalizable()->willReturn(true); + $damAsset->locale()->willReturn($locale); + $locale->__toString()->willReturn('en_US'); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn('en_US'); + $pimValue->getChannel()->shouldReturn(null); + } + + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( + DamAsset $damAsset, + DamAssetValue $damAssetValue, + AssetAttribute $attribute + ): void { + $attribute->isLocalizable()->willReturn(false); + + $damAssetValue->value()->willReturn('blue'); + + $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); + $pimValue->getAttribute()->shouldReturn($attribute); + $pimValue->getData()->shouldReturn('blue'); + $pimValue->getLocale()->shouldReturn(null); + $pimValue->getChannel()->shouldReturn(null); + } +} From 241d862cf20450f18ef3052e6ecf18b29efd1255 Mon Sep 17 00:00:00 2001 From: Willy Date: Wed, 25 Sep 2019 16:21:39 +0200 Subject: [PATCH 12/24] API-693: Update composer and sf.lock --- .gitignore | 3 - composer.json | 2 +- composer.lock | 678 ++++++++++++++++++++++++++++++++++++++++++++++++++ symfony.lock | 36 +++ 4 files changed, 715 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 59fb681..9ba184f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,6 @@ /public/ /var/ /vendor/ -/bin/ -/composer.lock -/symfony.lock ###< symfony/framework-bundle ### .idea/ diff --git a/composer.json b/composer.json index ee481be..63ba091 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "*": "dist" }, "sort-packages": true, - "bin-dir": "bin" + "bin-dir": "vendor/bin" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 8582956..9890c21 100644 --- a/composer.lock +++ b/composer.lock @@ -3045,6 +3045,62 @@ ], "time": "2019-08-08T18:11:40+00:00" }, + { + "name": "doctrine/instantiator", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "a2c590166b2133a4633738648b6b064edae0814a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2019-03-17T17:37:11+00:00" + }, { "name": "doctrine/lexer", "version": "1.1.0", @@ -3247,6 +3303,578 @@ ], "time": "2018-02-15T16:58:55+00:00" }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2018-08-07T13:53:10+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "^1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2019-09-12T14:27:41+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" + }, + { + "name": "phpspec/php-diff", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/0464787bfa7cd13576c5a1e318709768798bec6a", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2016-04-07T12:29:16+00:00" + }, + { + "name": "phpspec/phpspec", + "version": "4.3.4", + "source": { + "type": "git", + "url": "https://github.com/phpspec/phpspec.git", + "reference": "a601fa68ccb42dbcff4a55e462e780700c4811ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/a601fa68ccb42dbcff4a55e462e780700c4811ee", + "reference": "a601fa68ccb42dbcff4a55e462e780700c4811ee", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.5", + "ext-tokenizer": "*", + "php": "^7.0,<7.3", + "phpspec/php-diff": "^1.0.0", + "phpspec/prophecy": "^1.6", + "sebastian/exporter": "^1.0 || ^2.0 || ^3.0", + "symfony/console": "^3.2 || ^4.0", + "symfony/event-dispatcher": "^3.2 || ^4.0", + "symfony/finder": "^3.2 || ^4.0", + "symfony/process": "^3.2 || ^4.0", + "symfony/yaml": "^3.2 || ^4.0" + }, + "require-dev": { + "behat/behat": "^3.3", + "phpunit/phpunit": "^5.7|^6.0", + "symfony/filesystem": "^3.2 || ^4.0" + }, + "suggest": { + "phpspec/nyan-formatters": "Adds Nyan formatters" + }, + "bin": [ + "bin/phpspec" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpSpec": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "homepage": "http://marcelloduarte.net/" + }, + { + "name": "Ciaran McNulty", + "homepage": "https://ciaranmcnulty.com/" + } + ], + "description": "Specification-oriented BDD framework for PHP 5.6+", + "homepage": "http://phpspec.net/", + "keywords": [ + "BDD", + "SpecBDD", + "TDD", + "spec", + "specification", + "testing", + "tests" + ], + "time": "2019-08-05T09:27:18+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2019-06-13T12:50:23+00:00" + }, + { + "name": "sebastian/comparator", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "shasum": "" + }, + "require": { + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2018-07-12T15:12:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2019-02-04T06:01:07+00:00" + }, + { + "name": "sebastian/exporter", + "version": "3.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2019-09-14T09:02:43+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" + }, { "name": "symfony/options-resolver", "version": "v4.3.4", @@ -3399,6 +4027,56 @@ "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", "time": "2019-08-07T11:52:19+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^7.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2019-08-24T08:43:50+00:00" } ], "aliases": [], diff --git a/symfony.lock b/symfony.lock index bb3d584..3fbd10a 100644 --- a/symfony.lock +++ b/symfony.lock @@ -35,6 +35,9 @@ "doctrine/event-manager": { "version": "1.0.x-dev" }, + "doctrine/instantiator": { + "version": "1.2.0" + }, "doctrine/lexer": { "version": "1.2.x-dev" }, @@ -83,6 +86,24 @@ "php-http/promise": { "version": "1.0-dev" }, + "phpdocumentor/reflection-common": { + "version": "2.0.0" + }, + "phpdocumentor/reflection-docblock": { + "version": "4.3.2" + }, + "phpdocumentor/type-resolver": { + "version": "1.0.1" + }, + "phpspec/php-diff": { + "version": "v1.1.0" + }, + "phpspec/phpspec": { + "version": "4.3.4" + }, + "phpspec/prophecy": { + "version": "1.8.1" + }, "psr/cache": { "version": "1.0.1" }, @@ -104,6 +125,18 @@ "ralouphie/getallheaders": { "version": "3.0.3" }, + "sebastian/comparator": { + "version": "3.0.2" + }, + "sebastian/diff": { + "version": "3.0.2" + }, + "sebastian/exporter": { + "version": "3.1.2" + }, + "sebastian/recursion-context": { + "version": "3.0.0" + }, "symfony/cache": { "version": "v4.3.3" }, @@ -231,5 +264,8 @@ }, "symfony/yaml": { "version": "v4.3.3" + }, + "webmozart/assert": { + "version": "1.5.0" } } From c6967e85c3ae2b26f0362213128062919fee3818 Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 09:59:06 +0200 Subject: [PATCH 13/24] API-693: Add builders for spec purpose --- .../Specification/Builder/DamAssetBuilder.php | 31 +++++++++++++++++++ .../Specification/Builder/PimAssetBuilder.php | 17 ++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/Specification/Builder/DamAssetBuilder.php create mode 100644 tests/Specification/Builder/PimAssetBuilder.php diff --git a/tests/Specification/Builder/DamAssetBuilder.php b/tests/Specification/Builder/DamAssetBuilder.php new file mode 100644 index 0000000..f8c339e --- /dev/null +++ b/tests/Specification/Builder/DamAssetBuilder.php @@ -0,0 +1,31 @@ + $value) { + $damAsset->addValue($property, $value); + } + + return $damAsset; + } +} diff --git a/tests/Specification/Builder/PimAssetBuilder.php b/tests/Specification/Builder/PimAssetBuilder.php new file mode 100644 index 0000000..f6d55bc --- /dev/null +++ b/tests/Specification/Builder/PimAssetBuilder.php @@ -0,0 +1,17 @@ + Date: Thu, 26 Sep 2019 09:59:34 +0200 Subject: [PATCH 14/24] API-693: fix Synchronize assets --- .../Service/SynchronizeAssetsSpec.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Specification/Application/Service/SynchronizeAssetsSpec.php b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php index 766e6f7..e56d7cd 100644 --- a/tests/Specification/Application/Service/SynchronizeAssetsSpec.php +++ b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php @@ -7,11 +7,10 @@ use AkeneoDAMConnector\Application\Mapping\AssetTransformer; use AkeneoDAMConnector\Application\PimAdapter\UpdateAsset; use AkeneoDAMConnector\Application\Service\SynchronizeAssets; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\PimAsset; use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Tests\Specification\Builder\PimAssetBuilder; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; class SynchronizeAssetsSpec extends ObjectBehavior { @@ -32,13 +31,14 @@ function it_synchronizes_assets( $fetchAssets, $assetTransformer, $assetApi, - DamAsset $damTable, - DamAsset $damMug, - PimAsset $pimTable, - PimAsset $pimMug, - \Iterator $damAssets, - AssetFamilyCode $assetFamilyCode + \Iterator $damAssets ) { + $assetFamilyCode = new AssetFamilyCode('packshot'); + $damTable = DamAssetBuilder::build('table', 'packshot'); + $damMug = DamAssetBuilder::build('mug', 'packshot'); + $pimTable = PimAssetBuilder::build('table', 'packshot'); + $pimMug = PimAssetBuilder::build('mug', 'packshot'); + $damAssets->rewind()->shouldBeCalled(); $damAssets->valid()->willReturn(true, true, false); $damAssets->current()->willReturn($damTable, $damMug); From 616cb1a37232dc79cf1e76d1dc3779397f1dcde8 Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 10:22:22 +0200 Subject: [PATCH 15/24] API-693: Fix asset attribute builder spec --- .../Mapping/AssetAttributeBuilderSpec.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php index 75e485b..d9d7628 100644 --- a/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php +++ b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php @@ -21,15 +21,12 @@ function it_is_initializable(): void $this->shouldHaveType(AssetAttributeBuilder::class); } - function it_builds_an_attribute( - $structureConfigLoader, - AssetFamilyCode $familyCode, - AssetAttributeCode $attributeCode - ): void { + function it_builds_an_attribute($structureConfigLoader): void + { $structureConfigLoader->load()->willReturn($this->getConfig()); - $familyCode->__toString()->willReturn('packshot'); - $attributeCode->__toString()->willReturn('locale'); + $familyCode = new AssetFamilyCode('packshot'); + $attributeCode = new AssetAttributeCode('locale'); $attribute = $this->build($familyCode, $attributeCode); $attribute->getCode()->shouldReturn($attributeCode); @@ -37,15 +34,12 @@ function it_builds_an_attribute( $attribute->isLocalizable()->shouldReturn(false); } - function it_throws_an_exception_if_attribute_does_not_exist( - $structureConfigLoader, - AssetFamilyCode $familyCode, - AssetAttributeCode $attributeCode - ): void { + function it_throws_an_exception_if_attribute_does_not_exist($structureConfigLoader): void + { $structureConfigLoader->load()->willReturn($this->getConfig()); - $familyCode->__toString()->willReturn('packshot'); - $attributeCode->__toString()->willReturn('description'); + $familyCode = new AssetFamilyCode('packshot'); + $attributeCode = new AssetAttributeCode('description'); $this ->shouldThrow( From c9bc29019a55e303aea109d0ea27fc1a35bc7c40 Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 10:25:44 +0200 Subject: [PATCH 16/24] API-693: Fix asset mapper spec --- .../Application/Mapping/AssetMapperSpec.php | 27 +++++++++---------- .../Builder/AssetAttributeBuilder.php | 15 +++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 tests/Specification/Builder/AssetAttributeBuilder.php diff --git a/tests/Specification/Application/Mapping/AssetMapperSpec.php b/tests/Specification/Application/Mapping/AssetMapperSpec.php index b4fa7a9..096deac 100644 --- a/tests/Specification/Application/Mapping/AssetMapperSpec.php +++ b/tests/Specification/Application/Mapping/AssetMapperSpec.php @@ -5,11 +5,11 @@ use AkeneoDAMConnector\Application\ConfigLoader; use AkeneoDAMConnector\Application\Mapping\AssetAttributeBuilder; -use AkeneoDAMConnector\Domain\AssetAttribute; use AkeneoDAMConnector\Domain\AssetAttributeCode; use AkeneoDAMConnector\Domain\AssetFamilyCode; use AkeneoDAMConnector\Domain\Exception\AttributeMappingNotFound; use AkeneoDAMConnector\Domain\Exception\FamilyMappingNotFound; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder as TestAttributeBuilder; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -20,18 +20,18 @@ public function let(ConfigLoader $mappingConfigLoader, AssetAttributeBuilder $as $this->beConstructedWith($mappingConfigLoader, $assetAttributeBuilder); } - public function it_provides_mapped_properties_of_a_family($mappingConfigLoader, AssetFamilyCode $familyCode) + public function it_provides_mapped_properties_of_a_family($mappingConfigLoader): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode->__toString()->willReturn('packshot'); + $familyCode = new AssetFamilyCode('packshot'); $this->getMappedProperties($familyCode)->shouldReturn(['sku', 'url', 'colors']); } - public function it_throws_an_exception_if_not_mapping_can_be_provided($mappingConfigLoader, AssetFamilyCode $familyCode) + public function it_throws_an_exception_if_not_mapping_can_be_provided($mappingConfigLoader): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode->__toString()->willReturn('family'); + $familyCode = new AssetFamilyCode('family'); $this ->shouldThrow( @@ -42,12 +42,12 @@ public function it_throws_an_exception_if_not_mapping_can_be_provided($mappingCo public function it_maps_a_dam_property_to_a_pim_attribute( $mappingConfigLoader, - $assetAttributeBuilder, - AssetFamilyCode $familyCode, - AssetAttribute $attribute - ) { + $assetAttributeBuilder + ): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode->__toString()->willReturn('packshot'); + $familyCode = new AssetFamilyCode('packshot'); + $attribute = TestAttributeBuilder::build('preview', 'text'); + $assetAttributeBuilder ->build('packshot', Argument::that(function ($argument) { return $argument instanceof AssetAttributeCode && @@ -60,11 +60,10 @@ public function it_maps_a_dam_property_to_a_pim_attribute( } public function it_throws_an_exception_if_the_dam_property_does_not_match_a_pim_attribute( - $mappingConfigLoader, - AssetFamilyCode $familyCode - ) { + $mappingConfigLoader + ): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode->__toString()->willReturn('packshot'); + $familyCode = new AssetFamilyCode('packshot'); $this ->shouldThrow( diff --git a/tests/Specification/Builder/AssetAttributeBuilder.php b/tests/Specification/Builder/AssetAttributeBuilder.php new file mode 100644 index 0000000..cb9330f --- /dev/null +++ b/tests/Specification/Builder/AssetAttributeBuilder.php @@ -0,0 +1,15 @@ + Date: Thu, 26 Sep 2019 11:02:52 +0200 Subject: [PATCH 17/24] API-693: Fix asset transformer spec --- .../Mapping/AssetTransformerSpec.php | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetTransformerSpec.php b/tests/Specification/Application/Mapping/AssetTransformerSpec.php index 16917f2..c2a6f7e 100644 --- a/tests/Specification/Application/Mapping/AssetTransformerSpec.php +++ b/tests/Specification/Application/Mapping/AssetTransformerSpec.php @@ -5,12 +5,11 @@ use AkeneoDAMConnector\Application\Mapping\AssetConverter; use AkeneoDAMConnector\Application\Mapping\AssetMapper; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetIdentifier; use AkeneoDAMConnector\Domain\Asset\DamAssetValue; use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -23,31 +22,28 @@ public function let( $this->beConstructedWith($assetMapper, $assetConverter); } - public function it_transforms_a_dam_asset_to_pim_asset( - $assetMapper, - $assetConverter, - DamAsset $damAsset, - AssetFamilyCode $familyCode, - DamAssetValue $skuValue, - DamAssetValue $colorsValue, - DamAssetValue $designedByValue, - DamAssetIdentifier $damIdentifier, - AssetAttribute $skuAttribute, - AssetAttribute $colorsAttribute, - PimAssetValue $skuPimValue, - PimAssetValue $colorsPimValue - ): void { + public function it_transforms_a_dam_asset_to_pim_asset($assetMapper, $assetConverter): void + { $mappedProperties = ['sku', 'colors', 'url']; - $damValues = [ - 'sku' => $skuValue, - 'colors' => $colorsValue, - 'designed_by' => $designedByValue, - ]; - $damAsset->assetFamilyCode()->willReturn($familyCode); - $damAsset->getValues()->willReturn($damValues); - $damAsset->damAssetIdentifier()->willReturn($damIdentifier); - $damIdentifier->__toString()->willReturn('dam_identifier'); + $familyCode = new AssetFamilyCode('packshot'); + $damAsset = DamAssetBuilder::build( + 'dam_identifier', + 'packshot', + [ + 'sku' => '123456', + 'colors' => 'blue, green', + 'designed_by' => 'stark', + ] + ); + $skuValue = new DamAssetValue('sku', '123456'); + $colorsValue = new DamAssetValue('colors', 'blue, green'); + $designedByValue = new DamAssetValue('designed_by', 'stark'); + + $skuAttribute = AssetAttributeBuilder::build('sku', 'text'); + $colorsAttribute = AssetAttributeBuilder::build('all_colors', 'multiple_options'); + $skuPimValue = new PimAssetValue($skuAttribute, '123456'); + $colorsPimValue = new PimAssetValue($colorsAttribute, ['blue', 'green']); $assetMapper->getMappedProperties($familyCode)->willReturn($mappedProperties); $assetMapper->mapAttribute($familyCode, 'sku')->willReturn($skuAttribute); @@ -63,5 +59,20 @@ public function it_transforms_a_dam_asset_to_pim_asset( $pimAsset = $this->damToPim($damAsset); $pimAsset->getCode()->shouldReturn('dam_identifier'); + $pimAsset->normalize()->shouldReturn([ + 'code' => 'dam_identifier', + 'values' => [ + 'sku' => [[ + 'locale' => null, + 'channel' => null, + 'data' => '123456', + ]], + 'all_colors' => [[ + 'locale' => null, + 'channel' => null, + 'data' => ['blue', 'green'], + ]], + ] + ]); } } From 33f1d43834bbab576333567cb811833ce88c4415 Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 11:10:37 +0200 Subject: [PATCH 18/24] API-693: Fix media link converter spec --- .../MediaLinkConverterSpec.php | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php index 87a0c86..7649fd8 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php @@ -5,10 +5,9 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\MediaLinkConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; class MediaLinkConverterSpec extends ObjectBehavior @@ -24,37 +23,28 @@ public function it_provides_a_supported_type(): void $this->getSupportedType()->shouldReturn('media_link'); } - public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute, - Locale $locale - ): void { - $attribute->isLocalizable()->willReturn(true); - $damAsset->locale()->willReturn($locale); - $locale->__toString()->willReturn('en_US'); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['url' => 'here.com'], 'en_US'); + $attribute = AssetAttributeBuilder::build('url', 'media_link', true); + $damAssetValue = new DamAssetValue('url', 'here.com'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('here.com'); $pimValue->getLocale()->shouldReturn('en_US'); $pimValue->getChannel()->shouldReturn(null); } - public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute - ): void { - $attribute->isLocalizable()->willReturn(false); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['url' => 'here.com']); + $attribute = AssetAttributeBuilder::build('url', 'media_link', false); + $damAssetValue = new DamAssetValue('url', 'here.com'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('here.com'); $pimValue->getLocale()->shouldReturn(null); $pimValue->getChannel()->shouldReturn(null); } From 08bef4c4dc456daaebf4370bf326e9b7abe44f52 Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 11:23:32 +0200 Subject: [PATCH 19/24] API-693: Fix multi option converter spec --- .../MultiOptionConverterSpec.php | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php index a6d7c46..6cb67fa 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php @@ -5,15 +5,13 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\MultiOptionConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; class MultiOptionConverterSpec extends ObjectBehavior { - public function it_is_a_multi_option_converter(): void { $this->shouldHaveType(MultiOptionConverter::class); @@ -25,35 +23,28 @@ public function it_provides_a_supported_type(): void $this->getSupportedType()->shouldReturn('multiple_options'); } - public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute, - Locale $locale - ): void { - $damAssetValue->value()->willReturn('blue, yellow, brown'); - $attribute->isLocalizable()->willReturn(true); - $damAsset->locale()->willReturn($locale); - $locale->__toString()->willReturn('en_US'); + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['colors' => 'simic, blue, green'], 'en_US'); + $attribute = AssetAttributeBuilder::build('colors', 'multiple_options', true); + $damAssetValue = new DamAssetValue('colors', 'simic, blue, green'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn(['blue', 'yellow', 'brown']); + $pimValue->getData()->shouldReturn(['simic', 'blue', 'green']); $pimValue->getLocale()->shouldReturn('en_US'); $pimValue->getChannel()->shouldReturn(null); } - public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute - ): void { - $damAssetValue->value()->willReturn('blue, yellow, brown'); - $attribute->isLocalizable()->willReturn(false); + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['colors' => 'simic, blue, green']); + $attribute = AssetAttributeBuilder::build('colors', 'multiple_options', false); + $damAssetValue = new DamAssetValue('colors', 'simic, blue, green'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn(['blue', 'yellow', 'brown']); + $pimValue->getData()->shouldReturn(['simic', 'blue', 'green']); $pimValue->getLocale()->shouldReturn(null); $pimValue->getChannel()->shouldReturn(null); } From 2a6f8ef1e9fe097bd3ca6c38d3f2bbd5cfb1efff Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 11:36:41 +0200 Subject: [PATCH 20/24] API-693: Fix single option converter spec --- .../SingleOptionConverterSpec.php | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php index dd75d7e..9cf4928 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php @@ -5,10 +5,9 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\SingleOptionConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; class SingleOptionConverterSpec extends ObjectBehavior @@ -24,37 +23,28 @@ public function it_provides_a_supported_type(): void $this->getSupportedType()->shouldReturn('single_option'); } - public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute, - Locale $locale - ): void { - $attribute->isLocalizable()->willReturn(true); - $damAsset->locale()->willReturn($locale); - $locale->__toString()->willReturn('en_US'); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['color' => 'temur'], 'en_US'); + $attribute = AssetAttributeBuilder::build('color', 'single_option', true); + $damAssetValue = new DamAssetValue('color', 'temur'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('temur'); $pimValue->getLocale()->shouldReturn('en_US'); $pimValue->getChannel()->shouldReturn(null); } - public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute - ): void { - $attribute->isLocalizable()->willReturn(false); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['color' => 'temur']); + $attribute = AssetAttributeBuilder::build('color', 'single_option', false); + $damAssetValue = new DamAssetValue('color', 'temur'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('temur'); $pimValue->getLocale()->shouldReturn(null); $pimValue->getChannel()->shouldReturn(null); } From db5c9ff6269f991f1c6cbc855a963ce84dfbb41c Mon Sep 17 00:00:00 2001 From: Willy Date: Thu, 26 Sep 2019 11:39:31 +0200 Subject: [PATCH 21/24] API-693: fix test converter spec --- .../AssetValueConverter/TextConverterSpec.php | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php index ccb66c3..82f8ed7 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php @@ -9,6 +9,8 @@ use AkeneoDAMConnector\Domain\Asset\DamAssetValue; use AkeneoDAMConnector\Domain\AssetAttribute; use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; +use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; class TextConverterSpec extends ObjectBehavior @@ -24,37 +26,28 @@ public function it_provides_a_supported_type(): void $this->getSupportedType()->shouldReturn('text'); } - public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute, - Locale $locale - ): void { - $attribute->isLocalizable()->willReturn(true); - $damAsset->locale()->willReturn($locale); - $locale->__toString()->willReturn('en_US'); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['description' => 'pretty'], 'en_US'); + $attribute = AssetAttributeBuilder::build('description', 'text', true); + $damAssetValue = new DamAssetValue('description', 'pretty'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('pretty'); $pimValue->getLocale()->shouldReturn('en_US'); $pimValue->getChannel()->shouldReturn(null); } - public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value( - DamAsset $damAsset, - DamAssetValue $damAssetValue, - AssetAttribute $attribute - ): void { - $attribute->isLocalizable()->willReturn(false); - - $damAssetValue->value()->willReturn('blue'); + public function it_converts_a_dam_asset_value_into_a_not_localized_pim_asset_value(): void + { + $damAsset = DamAssetBuilder::build('table', 'packshot', ['description' => 'pretty']); + $attribute = AssetAttributeBuilder::build('description', 'text', false); + $damAssetValue = new DamAssetValue('description', 'pretty'); $pimValue = $this->convert($damAsset, $damAssetValue, $attribute); $pimValue->getAttribute()->shouldReturn($attribute); - $pimValue->getData()->shouldReturn('blue'); + $pimValue->getData()->shouldReturn('pretty'); $pimValue->getLocale()->shouldReturn(null); $pimValue->getChannel()->shouldReturn(null); } From 59ed2d3e2b2701b7ad30076d07e2c9f94c8847c5 Mon Sep 17 00:00:00 2001 From: Willy Mesnage Date: Thu, 26 Sep 2019 14:07:12 +0200 Subject: [PATCH 22/24] Update tests/Specification/Application/Mapping/AssetMapperSpec.php Co-Authored-By: Paul --- tests/Specification/Application/Mapping/AssetMapperSpec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Specification/Application/Mapping/AssetMapperSpec.php b/tests/Specification/Application/Mapping/AssetMapperSpec.php index 096deac..d5fca4b 100644 --- a/tests/Specification/Application/Mapping/AssetMapperSpec.php +++ b/tests/Specification/Application/Mapping/AssetMapperSpec.php @@ -28,7 +28,7 @@ public function it_provides_mapped_properties_of_a_family($mappingConfigLoader): $this->getMappedProperties($familyCode)->shouldReturn(['sku', 'url', 'colors']); } - public function it_throws_an_exception_if_not_mapping_can_be_provided($mappingConfigLoader): void + public function it_throws_an_exception_if_no_mapping_can_be_provided($mappingConfigLoader): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); $familyCode = new AssetFamilyCode('family'); From ace469a33cd78aa93d76efb50bf4e2ce79dbf553 Mon Sep 17 00:00:00 2001 From: Willy Date: Fri, 27 Sep 2019 11:19:45 +0200 Subject: [PATCH 23/24] Clean Domain models --- src/Application/DamAdapter/FetchAssets.php | 4 +-- .../Mapping/AssetAttributeBuilder.php | 12 ++++----- src/Application/Mapping/AssetConverter.php | 10 +++---- src/Application/Mapping/AssetMapper.php | 18 ++++++------- src/Application/Mapping/AssetTransformer.php | 6 ++--- .../Mapping/AssetValueConverter.php | 10 +++---- .../MediaLinkConverter.php | 10 +++---- .../MultiOptionConverter.php | 10 +++---- .../SingleOptionConverter.php | 10 +++---- .../AssetValueConverter/TextConverter.php | 10 +++---- src/Application/PimAdapter/UpdateAsset.php | 8 +++--- src/Application/Service/SynchronizeAssets.php | 4 +-- src/Domain/{Asset => Model/Dam}/DamAsset.php | 12 ++++----- .../Dam}/DamAssetCollection.php | 2 +- .../Dam}/DamAssetIdentifier.php | 11 +------- .../{Asset => Model/Dam}/DamAssetValue.php | 11 +------- .../FamilyCode.php} | 4 +-- src/Domain/{ => Model}/Locale.php | 2 +- .../Pim/Attribute.php} | 8 +++--- .../Pim/AttributeCode.php} | 4 +-- src/Domain/{Asset => Model/Pim}/PimAsset.php | 8 +++--- .../Pim}/PimAssetCollection.php | 2 +- .../{Asset => Model/Pim}/PimAssetValue.php | 12 ++++----- src/Domain/ResourceType.php | 27 ------------------- .../Command/SynchronizeAssetsCommand.php | 4 +-- .../DAM/DamExample/FetchAssets.php | 10 +++---- .../Pim/AttributeOptionsApi.php | 6 ++--- src/Infrastructure/Pim/UpdateAssetApi.php | 8 +++--- .../Mapping/AssetAttributeBuilderSpec.php | 12 ++++----- .../Application/Mapping/AssetMapperSpec.php | 14 +++++----- .../Mapping/AssetTransformerSpec.php | 8 +++--- .../MediaLinkConverterSpec.php | 2 +- .../MultiOptionConverterSpec.php | 2 +- .../SingleOptionConverterSpec.php | 2 +- .../AssetValueConverter/TextConverterSpec.php | 8 +++--- .../Service/SynchronizeAssetsSpec.php | 4 +-- .../Builder/AssetAttributeBuilder.php | 8 +++--- .../Specification/Builder/DamAssetBuilder.php | 10 +++---- .../Specification/Builder/PimAssetBuilder.php | 6 ++--- 39 files changed, 137 insertions(+), 182 deletions(-) rename src/Domain/{Asset => Model/Dam}/DamAsset.php (80%) rename src/Domain/{Asset => Model/Dam}/DamAssetCollection.php (95%) rename src/Domain/{Asset => Model/Dam}/DamAssetIdentifier.php (53%) rename src/Domain/{Asset => Model/Dam}/DamAssetValue.php (61%) rename src/Domain/{AssetFamilyCode.php => Model/FamilyCode.php} (79%) rename src/Domain/{ => Model}/Locale.php (91%) rename src/Domain/{AssetAttribute.php => Model/Pim/Attribute.php} (68%) rename src/Domain/{AssetAttributeCode.php => Model/Pim/AttributeCode.php} (77%) rename src/Domain/{Asset => Model/Pim}/PimAsset.php (83%) rename src/Domain/{Asset => Model/Pim}/PimAssetCollection.php (94%) rename src/Domain/{Asset => Model/Pim}/PimAssetValue.php (70%) delete mode 100644 src/Domain/ResourceType.php diff --git a/src/Application/DamAdapter/FetchAssets.php b/src/Application/DamAdapter/FetchAssets.php index 03f1c36..e5ab5d7 100644 --- a/src/Application/DamAdapter/FetchAssets.php +++ b/src/Application/DamAdapter/FetchAssets.php @@ -4,12 +4,12 @@ namespace AkeneoDAMConnector\Application\DamAdapter; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; interface FetchAssets { /** * Fetches assets on DAM third party system depending on the last fetch date. */ - public function fetch(AssetFamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): \Iterator; + public function fetch(FamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): \Iterator; } diff --git a/src/Application/Mapping/AssetAttributeBuilder.php b/src/Application/Mapping/AssetAttributeBuilder.php index 40ebbd2..37d50a4 100644 --- a/src/Application/Mapping/AssetAttributeBuilder.php +++ b/src/Application/Mapping/AssetAttributeBuilder.php @@ -6,9 +6,9 @@ namespace AkeneoDAMConnector\Application\Mapping; use AkeneoDAMConnector\Application\ConfigLoader; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\AssetAttributeCode; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class AssetAttributeBuilder { @@ -20,11 +20,11 @@ public function __construct(ConfigLoader $structureConfigLoader) $this->structureConfigLoader = $structureConfigLoader; } - public function build(AssetFamilyCode $familyCode, AssetAttributeCode $attributeCode): AssetAttribute + public function build(FamilyCode $familyCode, AttributeCode $attributeCode): Attribute { $attributeType = $this->getAttributeType($familyCode, $attributeCode); - return new AssetAttribute($attributeCode, $attributeType, false); + return new Attribute($attributeCode, $attributeType, false); } private function getStructureConfig(): array @@ -36,7 +36,7 @@ private function getStructureConfig(): array return $this->structureConfig; } - private function getAttributeType(AssetFamilyCode $familyCode, AssetAttributeCode $attributeCode): string + private function getAttributeType(FamilyCode $familyCode, AttributeCode $attributeCode): string { foreach ($this->getStructureConfig()[(string)$familyCode]['attributes'] as $attribute) { if ($attribute['code'] === (string)$attributeCode) { diff --git a/src/Application/Mapping/AssetConverter.php b/src/Application/Mapping/AssetConverter.php index 840aec7..9198ce8 100644 --- a/src/Application/Mapping/AssetConverter.php +++ b/src/Application/Mapping/AssetConverter.php @@ -4,10 +4,10 @@ namespace AkeneoDAMConnector\Application\Mapping; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; class AssetConverter { @@ -18,7 +18,7 @@ public function __construct(AssetValueConverterRegistry $registry) $this->registry = $registry; } - public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, AssetAttribute $attribute): PimAssetValue + public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, Attribute $attribute): PimAssetValue { return $this->registry->getConverter($attribute->getType())->convert( $damAsset, diff --git a/src/Application/Mapping/AssetMapper.php b/src/Application/Mapping/AssetMapper.php index 733f6b0..5446334 100644 --- a/src/Application/Mapping/AssetMapper.php +++ b/src/Application/Mapping/AssetMapper.php @@ -5,9 +5,9 @@ namespace AkeneoDAMConnector\Application\Mapping; use AkeneoDAMConnector\Application\ConfigLoader; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\AssetAttributeCode; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use AkeneoDAMConnector\Domain\Exception\AttributeMappingNotFound; use AkeneoDAMConnector\Domain\Exception\FamilyMappingNotFound; @@ -24,15 +24,15 @@ public function __construct(ConfigLoader $mappingConfigLoader, AssetAttributeBui $this->assetAttributeBuilder = $assetAttributeBuilder; } - public function getMappedProperties(AssetFamilyCode $familyCode): array + public function getMappedProperties(FamilyCode $familyCode): array { return array_keys($this->getFamilyMapping($familyCode)); } public function mapAttribute( - AssetFamilyCode $familyCode, + FamilyCode $familyCode, string $damAttributeProperty - ): AssetAttribute { + ): Attribute { $attributeCode = $this->getAttributeCodeFromFamilyMapping( $this->getFamilyMapping($familyCode), $damAttributeProperty @@ -50,7 +50,7 @@ private function getMappingConfig(): array return $this->mappingConfig; } - private function getFamilyMapping(AssetFamilyCode $familyCode): array + private function getFamilyMapping(FamilyCode $familyCode): array { $mapping = $this->getMappingConfig(); @@ -64,11 +64,11 @@ private function getFamilyMapping(AssetFamilyCode $familyCode): array private function getAttributeCodeFromFamilyMapping( array $familyMapping, string $damAttributeProperty - ): AssetAttributeCode { + ): AttributeCode { if (!isset($familyMapping[$damAttributeProperty])) { throw new AttributeMappingNotFound(); } - return new AssetAttributeCode($familyMapping[$damAttributeProperty]); + return new AttributeCode($familyMapping[$damAttributeProperty]); } } diff --git a/src/Application/Mapping/AssetTransformer.php b/src/Application/Mapping/AssetTransformer.php index 166502b..0957080 100644 --- a/src/Application/Mapping/AssetTransformer.php +++ b/src/Application/Mapping/AssetTransformer.php @@ -4,9 +4,9 @@ namespace AkeneoDAMConnector\Application\Mapping; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\PimAsset; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Pim\PimAsset; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; class AssetTransformer { diff --git a/src/Application/Mapping/AssetValueConverter.php b/src/Application/Mapping/AssetValueConverter.php index 2ebe877..fd432a9 100644 --- a/src/Application/Mapping/AssetValueConverter.php +++ b/src/Application/Mapping/AssetValueConverter.php @@ -4,14 +4,14 @@ namespace AkeneoDAMConnector\Application\Mapping; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; interface AssetValueConverter { public function getSupportedType(): string; - public function convert(DamAsset $damAsset, DamAssetValue $asset, AssetAttribute $attribute): PimAssetValue; + public function convert(DamAsset $damAsset, DamAssetValue $asset, Attribute $attribute): PimAssetValue; } diff --git a/src/Application/Mapping/AssetValueConverter/MediaLinkConverter.php b/src/Application/Mapping/AssetValueConverter/MediaLinkConverter.php index 2c644ba..c1ac962 100644 --- a/src/Application/Mapping/AssetValueConverter/MediaLinkConverter.php +++ b/src/Application/Mapping/AssetValueConverter/MediaLinkConverter.php @@ -5,10 +5,10 @@ namespace AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; class MediaLinkConverter implements AssetValueConverter { @@ -17,7 +17,7 @@ public function getSupportedType(): string return 'media_link'; } - public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, AssetAttribute $attribute): PimAssetValue + public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, Attribute $attribute): PimAssetValue { $locale = $attribute->isLocalizable() ? (string)$damAsset->locale() : null; diff --git a/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php b/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php index fc8d526..603b880 100644 --- a/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php +++ b/src/Application/Mapping/AssetValueConverter/MultiOptionConverter.php @@ -5,10 +5,10 @@ namespace AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; class MultiOptionConverter implements AssetValueConverter { @@ -20,7 +20,7 @@ public function getSupportedType(): string public function convert( DamAsset $damAsset, DamAssetValue $damAssetValue, - AssetAttribute $attribute + Attribute $attribute ): PimAssetValue { $options = array_map( function ($option) { diff --git a/src/Application/Mapping/AssetValueConverter/SingleOptionConverter.php b/src/Application/Mapping/AssetValueConverter/SingleOptionConverter.php index d09ac89..6e2dd0c 100644 --- a/src/Application/Mapping/AssetValueConverter/SingleOptionConverter.php +++ b/src/Application/Mapping/AssetValueConverter/SingleOptionConverter.php @@ -5,10 +5,10 @@ namespace AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; class SingleOptionConverter implements AssetValueConverter { @@ -17,7 +17,7 @@ public function getSupportedType(): string return 'single_option'; } - public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, AssetAttribute $attribute): PimAssetValue + public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, Attribute $attribute): PimAssetValue { $locale = $attribute->isLocalizable() ? (string)$damAsset->locale() : null; diff --git a/src/Application/Mapping/AssetValueConverter/TextConverter.php b/src/Application/Mapping/AssetValueConverter/TextConverter.php index f98faa9..8877b9d 100644 --- a/src/Application/Mapping/AssetValueConverter/TextConverter.php +++ b/src/Application/Mapping/AssetValueConverter/TextConverter.php @@ -5,10 +5,10 @@ namespace AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; class TextConverter implements AssetValueConverter { @@ -17,7 +17,7 @@ public function getSupportedType(): string return 'text'; } - public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, AssetAttribute $attribute): PimAssetValue + public function convert(DamAsset $damAsset, DamAssetValue $damAssetValue, Attribute $attribute): PimAssetValue { $locale = $attribute->isLocalizable() ? (string)$damAsset->locale() : null; diff --git a/src/Application/PimAdapter/UpdateAsset.php b/src/Application/PimAdapter/UpdateAsset.php index f63582b..7d71959 100644 --- a/src/Application/PimAdapter/UpdateAsset.php +++ b/src/Application/PimAdapter/UpdateAsset.php @@ -4,12 +4,12 @@ namespace AkeneoDAMConnector\Application\PimAdapter; -use AkeneoDAMConnector\Domain\Asset\PimAsset; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\PimAsset; +use AkeneoDAMConnector\Domain\Model\FamilyCode; interface UpdateAsset { - public function upsert(AssetFamilyCode $assetFamilyCode, PimAsset $asset): void; + public function upsert(FamilyCode $assetFamilyCode, PimAsset $asset): void; - public function flush(AssetFamilyCode $assetFamilyCode): void; + public function flush(FamilyCode $assetFamilyCode): void; } diff --git a/src/Application/Service/SynchronizeAssets.php b/src/Application/Service/SynchronizeAssets.php index 3f0dcdc..a24ec02 100644 --- a/src/Application/Service/SynchronizeAssets.php +++ b/src/Application/Service/SynchronizeAssets.php @@ -7,7 +7,7 @@ use AkeneoDAMConnector\Application\DamAdapter\FetchAssets; use AkeneoDAMConnector\Application\Mapping\AssetTransformer; use AkeneoDAMConnector\Application\PimAdapter\UpdateAsset; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class SynchronizeAssets { @@ -30,7 +30,7 @@ public function __construct( $this->assetApi = $assetApi; } - public function execute(AssetFamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): void + public function execute(FamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): void { $damAssets = $this->fetchAssets->fetch($assetFamilyCode, $lastFetchDate); diff --git a/src/Domain/Asset/DamAsset.php b/src/Domain/Model/Dam/DamAsset.php similarity index 80% rename from src/Domain/Asset/DamAsset.php rename to src/Domain/Model/Dam/DamAsset.php index c7b62c2..2d235c5 100644 --- a/src/Domain/Asset/DamAsset.php +++ b/src/Domain/Model/Dam/DamAsset.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Dam; -use AkeneoDAMConnector\Domain\AssetFamilyCode; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Domain\Model\FamilyCode; +use AkeneoDAMConnector\Domain\Model\Locale; class DamAsset { /** @var DamAssetIdentifier */ private $damAssetIdentifier; - /** @var AssetFamilyCode */ + /** @var FamilyCode */ private $assetFamilyCode; /** @var Locale|null */ @@ -23,7 +23,7 @@ class DamAsset public function __construct( DamAssetIdentifier $damAssetIdentifier, - AssetFamilyCode $assetFamilyCode, + FamilyCode $assetFamilyCode, ?Locale $locale ) { $this->damAssetIdentifier = $damAssetIdentifier; @@ -42,7 +42,7 @@ public function damAssetIdentifier(): DamAssetIdentifier return $this->damAssetIdentifier; } - public function assetFamilyCode(): AssetFamilyCode + public function assetFamilyCode(): FamilyCode { return $this->assetFamilyCode; } diff --git a/src/Domain/Asset/DamAssetCollection.php b/src/Domain/Model/Dam/DamAssetCollection.php similarity index 95% rename from src/Domain/Asset/DamAssetCollection.php rename to src/Domain/Model/Dam/DamAssetCollection.php index f92d796..24d087a 100644 --- a/src/Domain/Asset/DamAssetCollection.php +++ b/src/Domain/Model/Dam/DamAssetCollection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Dam; /** * @author Willy Mesnage diff --git a/src/Domain/Asset/DamAssetIdentifier.php b/src/Domain/Model/Dam/DamAssetIdentifier.php similarity index 53% rename from src/Domain/Asset/DamAssetIdentifier.php rename to src/Domain/Model/Dam/DamAssetIdentifier.php index 66b1554..36bbd36 100644 --- a/src/Domain/Asset/DamAssetIdentifier.php +++ b/src/Domain/Model/Dam/DamAssetIdentifier.php @@ -2,16 +2,7 @@ declare(strict_types=1); -/* - * This file is part of the Akeneo PIM Enterprise Edition. - * - * (c) 2019 Akeneo SAS (http://www.akeneo.com) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Dam; /** * @author Romain Monceau diff --git a/src/Domain/Asset/DamAssetValue.php b/src/Domain/Model/Dam/DamAssetValue.php similarity index 61% rename from src/Domain/Asset/DamAssetValue.php rename to src/Domain/Model/Dam/DamAssetValue.php index 80e6067..1915e6d 100644 --- a/src/Domain/Asset/DamAssetValue.php +++ b/src/Domain/Model/Dam/DamAssetValue.php @@ -2,16 +2,7 @@ declare(strict_types=1); -/* - * This file is part of the Akeneo PIM Enterprise Edition. - * - * (c) 2019 Akeneo SAS (http://www.akeneo.com) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Dam; /** * @author Romain Monceau diff --git a/src/Domain/AssetFamilyCode.php b/src/Domain/Model/FamilyCode.php similarity index 79% rename from src/Domain/AssetFamilyCode.php rename to src/Domain/Model/FamilyCode.php index d641838..cf8ed7a 100644 --- a/src/Domain/AssetFamilyCode.php +++ b/src/Domain/Model/FamilyCode.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain; +namespace AkeneoDAMConnector\Domain\Model; -class AssetFamilyCode +class FamilyCode { private $code; diff --git a/src/Domain/Locale.php b/src/Domain/Model/Locale.php similarity index 91% rename from src/Domain/Locale.php rename to src/Domain/Model/Locale.php index 28ab13f..0bc0cb5 100644 --- a/src/Domain/Locale.php +++ b/src/Domain/Model/Locale.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain; +namespace AkeneoDAMConnector\Domain\Model; /** * @author Willy Mesnage diff --git a/src/Domain/AssetAttribute.php b/src/Domain/Model/Pim/Attribute.php similarity index 68% rename from src/Domain/AssetAttribute.php rename to src/Domain/Model/Pim/Attribute.php index 26a3ea3..678f9ff 100644 --- a/src/Domain/AssetAttribute.php +++ b/src/Domain/Model/Pim/Attribute.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain; +namespace AkeneoDAMConnector\Domain\Model\Pim; -class AssetAttribute +class Attribute { private $code; @@ -12,14 +12,14 @@ class AssetAttribute private $localizable; - public function __construct(AssetAttributeCode $code, string $type, bool $localizable) + public function __construct(AttributeCode $code, string $type, bool $localizable) { $this->code = $code; $this->type = $type; $this->localizable = $localizable; } - public function getCode(): AssetAttributeCode + public function getCode(): AttributeCode { return $this->code; } diff --git a/src/Domain/AssetAttributeCode.php b/src/Domain/Model/Pim/AttributeCode.php similarity index 77% rename from src/Domain/AssetAttributeCode.php rename to src/Domain/Model/Pim/AttributeCode.php index 6dfee9f..eb58fa0 100644 --- a/src/Domain/AssetAttributeCode.php +++ b/src/Domain/Model/Pim/AttributeCode.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain; +namespace AkeneoDAMConnector\Domain\Model\Pim; -class AssetAttributeCode +class AttributeCode { private $code; diff --git a/src/Domain/Asset/PimAsset.php b/src/Domain/Model/Pim/PimAsset.php similarity index 83% rename from src/Domain/Asset/PimAsset.php rename to src/Domain/Model/Pim/PimAsset.php index 9c169e1..5c9688d 100644 --- a/src/Domain/Asset/PimAsset.php +++ b/src/Domain/Model/Pim/PimAsset.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Pim; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class PimAsset { @@ -13,10 +13,10 @@ class PimAsset /** @var PimAssetValue[] */ private $values; - /** @var AssetFamilyCode */ + /** @var FamilyCode */ private $familyCode; - public function __construct(string $code, AssetFamilyCode $familyCode, array $values = []) + public function __construct(string $code, FamilyCode $familyCode, array $values = []) { $this->code = $code; $this->values = $values; diff --git a/src/Domain/Asset/PimAssetCollection.php b/src/Domain/Model/Pim/PimAssetCollection.php similarity index 94% rename from src/Domain/Asset/PimAssetCollection.php rename to src/Domain/Model/Pim/PimAssetCollection.php index 25592e1..30fa124 100644 --- a/src/Domain/Asset/PimAssetCollection.php +++ b/src/Domain/Model/Pim/PimAssetCollection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Pim; class PimAssetCollection implements \Iterator { diff --git a/src/Domain/Asset/PimAssetValue.php b/src/Domain/Model/Pim/PimAssetValue.php similarity index 70% rename from src/Domain/Asset/PimAssetValue.php rename to src/Domain/Model/Pim/PimAssetValue.php index 2b4417c..d2ae608 100644 --- a/src/Domain/Asset/PimAssetValue.php +++ b/src/Domain/Model/Pim/PimAssetValue.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace AkeneoDAMConnector\Domain\Asset; +namespace AkeneoDAMConnector\Domain\Model\Pim; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\AssetAttributeCode; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; class PimAssetValue { @@ -17,7 +17,7 @@ class PimAssetValue private $channel; - public function __construct(AssetAttribute $attribute, $data, ?string $locale = null, ?string $channel = null) + public function __construct(Attribute $attribute, $data, ?string $locale = null, ?string $channel = null) { $this->attribute = $attribute; $this->data = $data; @@ -25,12 +25,12 @@ public function __construct(AssetAttribute $attribute, $data, ?string $locale = $this->channel = $channel; } - public function getAttribute(): AssetAttribute + public function getAttribute(): Attribute { return $this->attribute; } - public function getAttributeCode(): AssetAttributeCode + public function getAttributeCode(): AttributeCode { return $this->attribute->getCode(); } diff --git a/src/Domain/ResourceType.php b/src/Domain/ResourceType.php deleted file mode 100644 index 71dc4d5..0000000 --- a/src/Domain/ResourceType.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -class ResourceType -{ - /** @var string */ - private $resourceType; - - public function __construct(string $resourceType) - { - if (!in_array($resourceType, ['image', 'other'])) { - $resourceType = 'other'; - } - $this->resourceType = $resourceType; - } - - public function __toString(): string - { - return $this->resourceType; - } -} diff --git a/src/Infrastructure/Command/SynchronizeAssetsCommand.php b/src/Infrastructure/Command/SynchronizeAssetsCommand.php index 3d498f7..f974d75 100644 --- a/src/Infrastructure/Command/SynchronizeAssetsCommand.php +++ b/src/Infrastructure/Command/SynchronizeAssetsCommand.php @@ -6,7 +6,7 @@ use AkeneoDAMConnector\Application\ConfigLoader; use AkeneoDAMConnector\Application\Service\SynchronizeAssets; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use AkeneoDAMConnector\Infrastructure\Persistence\Execution; use AkeneoDAMConnector\Infrastructure\Persistence\SynchronizeAssetsExecutionRepository; use Symfony\Component\Console\Command\Command; @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output) private function synchronizeFamily(string $familyCode, ?\DateTimeInterface $sinceLastSucceededExecutionTime): void { - $assetFamilyCode = new AssetFamilyCode($familyCode); + $assetFamilyCode = new FamilyCode($familyCode); $currentExecution = Execution::create($familyCode)->run(); $this->synchronizeAssetsExecutionRepository->save($currentExecution); diff --git a/src/Infrastructure/DAM/DamExample/FetchAssets.php b/src/Infrastructure/DAM/DamExample/FetchAssets.php index c63607e..b0df9e6 100644 --- a/src/Infrastructure/DAM/DamExample/FetchAssets.php +++ b/src/Infrastructure/DAM/DamExample/FetchAssets.php @@ -5,13 +5,13 @@ namespace AkeneoDAMConnector\Infrastructure\DAM\DamExample; use AkeneoDAMConnector\Application\DamAdapter\FetchAssets as FetchAssetsInterface; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetIdentifier; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetIdentifier; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class FetchAssets implements FetchAssetsInterface { - public function fetch(AssetFamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): \Iterator + public function fetch(FamilyCode $assetFamilyCode, ?\DateTimeInterface $lastFetchDate): \Iterator { $response = json_decode($this->getJson(), true); @@ -22,7 +22,7 @@ public function fetch(AssetFamilyCode $assetFamilyCode, ?\DateTimeInterface $las } } - private function denormalize(array $data, AssetFamilyCode $assetFamilyCode): DamAsset + private function denormalize(array $data, FamilyCode $assetFamilyCode): DamAsset { $asset = new DamAsset( new DamAssetIdentifier($data['uid']), diff --git a/src/Infrastructure/Pim/AttributeOptionsApi.php b/src/Infrastructure/Pim/AttributeOptionsApi.php index 0a17790..96436a8 100644 --- a/src/Infrastructure/Pim/AttributeOptionsApi.php +++ b/src/Infrastructure/Pim/AttributeOptionsApi.php @@ -5,7 +5,7 @@ namespace AkeneoDAMConnector\Infrastructure\Pim; use Akeneo\PimEnterprise\ApiClient\Api\AssetManager\AssetAttributeOptionApiInterface; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; /** * @author Willy Mesnage @@ -28,7 +28,7 @@ public function __construct(ClientBuilder $clientBuilder) $this->pimStructure = []; } - public function upsertAttributeOptions(AssetFamilyCode $familyCode, array $assetValues): void + public function upsertAttributeOptions(FamilyCode $familyCode, array $assetValues): void { if (!isset($this->attributeOptions[(string) $familyCode])) { $this->attributeOptions[(string) $familyCode] = []; @@ -51,7 +51,7 @@ public function upsertAttributeOptions(AssetFamilyCode $familyCode, array $asset } } - public function flush(AssetFamilyCode $familyCode): void + public function flush(FamilyCode $familyCode): void { foreach ($this->attributeOptions[(string) $familyCode] as $attributeCode => $attributeOptions) { $pimOptions = $this->get((string) $familyCode, $attributeCode); diff --git a/src/Infrastructure/Pim/UpdateAssetApi.php b/src/Infrastructure/Pim/UpdateAssetApi.php index 95c03dc..5d8745e 100644 --- a/src/Infrastructure/Pim/UpdateAssetApi.php +++ b/src/Infrastructure/Pim/UpdateAssetApi.php @@ -6,8 +6,8 @@ use Akeneo\PimEnterprise\ApiClient\Api\AssetManager\AssetApiInterface; use AkeneoDAMConnector\Application\PimAdapter\UpdateAsset; -use AkeneoDAMConnector\Domain\Asset\PimAsset; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\PimAsset; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class UpdateAssetApi implements UpdateAsset { @@ -27,7 +27,7 @@ public function __construct(ClientBuilder $clientBuilder, AttributeOptionsApi $a $this->attributeOptionsApi = $attributeOptionsApi; } - public function upsert(AssetFamilyCode $assetFamilyCode, PimAsset $asset): void + public function upsert(FamilyCode $assetFamilyCode, PimAsset $asset): void { $this->assets[(string) $assetFamilyCode][] = $asset->normalize(); $this->attributeOptionsApi->upsertAttributeOptions($assetFamilyCode, $asset->getAttributeOptions()); @@ -36,7 +36,7 @@ public function upsert(AssetFamilyCode $assetFamilyCode, PimAsset $asset): void } } - public function flush(AssetFamilyCode $assetFamilyCode): void + public function flush(FamilyCode $assetFamilyCode): void { $this->attributeOptionsApi->flush($assetFamilyCode); diff --git a/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php index d9d7628..4208020 100644 --- a/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php +++ b/tests/Specification/Application/Mapping/AssetAttributeBuilderSpec.php @@ -5,8 +5,8 @@ use AkeneoDAMConnector\Application\ConfigLoader; use AkeneoDAMConnector\Application\Mapping\AssetAttributeBuilder; -use AkeneoDAMConnector\Domain\AssetAttributeCode; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use PhpSpec\ObjectBehavior; class AssetAttributeBuilderSpec extends ObjectBehavior @@ -25,8 +25,8 @@ function it_builds_an_attribute($structureConfigLoader): void { $structureConfigLoader->load()->willReturn($this->getConfig()); - $familyCode = new AssetFamilyCode('packshot'); - $attributeCode = new AssetAttributeCode('locale'); + $familyCode = new FamilyCode('packshot'); + $attributeCode = new AttributeCode('locale'); $attribute = $this->build($familyCode, $attributeCode); $attribute->getCode()->shouldReturn($attributeCode); @@ -38,8 +38,8 @@ function it_throws_an_exception_if_attribute_does_not_exist($structureConfigLoad { $structureConfigLoader->load()->willReturn($this->getConfig()); - $familyCode = new AssetFamilyCode('packshot'); - $attributeCode = new AssetAttributeCode('description'); + $familyCode = new FamilyCode('packshot'); + $attributeCode = new AttributeCode('description'); $this ->shouldThrow( diff --git a/tests/Specification/Application/Mapping/AssetMapperSpec.php b/tests/Specification/Application/Mapping/AssetMapperSpec.php index d5fca4b..6f3690f 100644 --- a/tests/Specification/Application/Mapping/AssetMapperSpec.php +++ b/tests/Specification/Application/Mapping/AssetMapperSpec.php @@ -5,8 +5,8 @@ use AkeneoDAMConnector\Application\ConfigLoader; use AkeneoDAMConnector\Application\Mapping\AssetAttributeBuilder; -use AkeneoDAMConnector\Domain\AssetAttributeCode; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use AkeneoDAMConnector\Domain\Exception\AttributeMappingNotFound; use AkeneoDAMConnector\Domain\Exception\FamilyMappingNotFound; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder as TestAttributeBuilder; @@ -23,7 +23,7 @@ public function let(ConfigLoader $mappingConfigLoader, AssetAttributeBuilder $as public function it_provides_mapped_properties_of_a_family($mappingConfigLoader): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode = new AssetFamilyCode('packshot'); + $familyCode = new FamilyCode('packshot'); $this->getMappedProperties($familyCode)->shouldReturn(['sku', 'url', 'colors']); } @@ -31,7 +31,7 @@ public function it_provides_mapped_properties_of_a_family($mappingConfigLoader): public function it_throws_an_exception_if_no_mapping_can_be_provided($mappingConfigLoader): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode = new AssetFamilyCode('family'); + $familyCode = new FamilyCode('family'); $this ->shouldThrow( @@ -45,12 +45,12 @@ public function it_maps_a_dam_property_to_a_pim_attribute( $assetAttributeBuilder ): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode = new AssetFamilyCode('packshot'); + $familyCode = new FamilyCode('packshot'); $attribute = TestAttributeBuilder::build('preview', 'text'); $assetAttributeBuilder ->build('packshot', Argument::that(function ($argument) { - return $argument instanceof AssetAttributeCode && + return $argument instanceof AttributeCode && 'preview' === $argument->__toString(); })) ->shouldBeCalled() @@ -63,7 +63,7 @@ public function it_throws_an_exception_if_the_dam_property_does_not_match_a_pim_ $mappingConfigLoader ): void { $mappingConfigLoader->load()->willReturn($this->getMapping()); - $familyCode = new AssetFamilyCode('packshot'); + $familyCode = new FamilyCode('packshot'); $this ->shouldThrow( diff --git a/tests/Specification/Application/Mapping/AssetTransformerSpec.php b/tests/Specification/Application/Mapping/AssetTransformerSpec.php index c2a6f7e..bc020c1 100644 --- a/tests/Specification/Application/Mapping/AssetTransformerSpec.php +++ b/tests/Specification/Application/Mapping/AssetTransformerSpec.php @@ -5,9 +5,9 @@ use AkeneoDAMConnector\Application\Mapping\AssetConverter; use AkeneoDAMConnector\Application\Mapping\AssetMapper; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\Asset\PimAssetValue; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\PimAssetValue; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; @@ -26,7 +26,7 @@ public function it_transforms_a_dam_asset_to_pim_asset($assetMapper, $assetConve { $mappedProperties = ['sku', 'colors', 'url']; - $familyCode = new AssetFamilyCode('packshot'); + $familyCode = new FamilyCode('packshot'); $damAsset = DamAssetBuilder::build( 'dam_identifier', 'packshot', diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php index 7649fd8..9887b09 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MediaLinkConverterSpec.php @@ -5,7 +5,7 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\MediaLinkConverter; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php index 6cb67fa..ed580be 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/MultiOptionConverterSpec.php @@ -5,7 +5,7 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\MultiOptionConverter; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php index 9cf4928..ecd8671 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/SingleOptionConverterSpec.php @@ -5,7 +5,7 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\SingleOptionConverter; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; diff --git a/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php index 82f8ed7..1110bc1 100644 --- a/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php +++ b/tests/Specification/Application/Mapping/AssetValueConverter/TextConverterSpec.php @@ -5,10 +5,10 @@ use AkeneoDAMConnector\Application\Mapping\AssetValueConverter; use AkeneoDAMConnector\Application\Mapping\AssetValueConverter\TextConverter; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetValue; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetValue; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; +use AkeneoDAMConnector\Domain\Model\Locale; use AkeneoDAMConnector\Tests\Specification\Builder\AssetAttributeBuilder; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; use PhpSpec\ObjectBehavior; diff --git a/tests/Specification/Application/Service/SynchronizeAssetsSpec.php b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php index e56d7cd..242392c 100644 --- a/tests/Specification/Application/Service/SynchronizeAssetsSpec.php +++ b/tests/Specification/Application/Service/SynchronizeAssetsSpec.php @@ -7,7 +7,7 @@ use AkeneoDAMConnector\Application\Mapping\AssetTransformer; use AkeneoDAMConnector\Application\PimAdapter\UpdateAsset; use AkeneoDAMConnector\Application\Service\SynchronizeAssets; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\FamilyCode; use AkeneoDAMConnector\Tests\Specification\Builder\PimAssetBuilder; use PhpSpec\ObjectBehavior; use AkeneoDAMConnector\Tests\Specification\Builder\DamAssetBuilder; @@ -33,7 +33,7 @@ function it_synchronizes_assets( $assetApi, \Iterator $damAssets ) { - $assetFamilyCode = new AssetFamilyCode('packshot'); + $assetFamilyCode = new FamilyCode('packshot'); $damTable = DamAssetBuilder::build('table', 'packshot'); $damMug = DamAssetBuilder::build('mug', 'packshot'); $pimTable = PimAssetBuilder::build('table', 'packshot'); diff --git a/tests/Specification/Builder/AssetAttributeBuilder.php b/tests/Specification/Builder/AssetAttributeBuilder.php index cb9330f..cb370c7 100644 --- a/tests/Specification/Builder/AssetAttributeBuilder.php +++ b/tests/Specification/Builder/AssetAttributeBuilder.php @@ -3,13 +3,13 @@ namespace AkeneoDAMConnector\Tests\Specification\Builder; -use AkeneoDAMConnector\Domain\AssetAttribute; -use AkeneoDAMConnector\Domain\AssetAttributeCode; +use AkeneoDAMConnector\Domain\Model\Pim\Attribute; +use AkeneoDAMConnector\Domain\Model\Pim\AttributeCode; class AssetAttributeBuilder { - public static function build(string $code, string $type, bool $isLocalizable = false): AssetAttribute + public static function build(string $code, string $type, bool $isLocalizable = false): Attribute { - return new AssetAttribute(new AssetAttributeCode($code), $type, $isLocalizable); + return new Attribute(new AttributeCode($code), $type, $isLocalizable); } } diff --git a/tests/Specification/Builder/DamAssetBuilder.php b/tests/Specification/Builder/DamAssetBuilder.php index f8c339e..c75129e 100644 --- a/tests/Specification/Builder/DamAssetBuilder.php +++ b/tests/Specification/Builder/DamAssetBuilder.php @@ -3,10 +3,10 @@ namespace AkeneoDAMConnector\Tests\Specification\Builder; -use AkeneoDAMConnector\Domain\Asset\DamAsset; -use AkeneoDAMConnector\Domain\Asset\DamAssetIdentifier; -use AkeneoDAMConnector\Domain\AssetFamilyCode; -use AkeneoDAMConnector\Domain\Locale; +use AkeneoDAMConnector\Domain\Model\Dam\DamAsset; +use AkeneoDAMConnector\Domain\Model\Dam\DamAssetIdentifier; +use AkeneoDAMConnector\Domain\Model\FamilyCode; +use AkeneoDAMConnector\Domain\Model\Locale; class DamAssetBuilder { @@ -17,7 +17,7 @@ public static function build( ?string $locale = null ): DamAsset { $identifier = new DamAssetIdentifier($identifier); - $assetFamilyCode = new AssetFamilyCode($assetFamilyCode); + $assetFamilyCode = new FamilyCode($assetFamilyCode); $locale = null !== $locale ? new Locale($locale) : null; $damAsset = new DamAsset($identifier, $assetFamilyCode, $locale); diff --git a/tests/Specification/Builder/PimAssetBuilder.php b/tests/Specification/Builder/PimAssetBuilder.php index f6d55bc..e4f9e07 100644 --- a/tests/Specification/Builder/PimAssetBuilder.php +++ b/tests/Specification/Builder/PimAssetBuilder.php @@ -3,14 +3,14 @@ namespace AkeneoDAMConnector\Tests\Specification\Builder; -use AkeneoDAMConnector\Domain\Asset\PimAsset; -use AkeneoDAMConnector\Domain\AssetFamilyCode; +use AkeneoDAMConnector\Domain\Model\Pim\PimAsset; +use AkeneoDAMConnector\Domain\Model\FamilyCode; class PimAssetBuilder { public static function build(string $code, string $assetFamilyCode, array $values = []): PimAsset { - $familyCode = new AssetFamilyCode($assetFamilyCode); + $familyCode = new FamilyCode($assetFamilyCode); return new PimAsset($code, $familyCode, $values); } From 36e92637f805d82a67b17141d3bd00b00ac92471 Mon Sep 17 00:00:00 2001 From: romain Date: Fri, 4 Oct 2019 11:32:52 +0200 Subject: [PATCH 24/24] Update composer.lock --- composer.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index 9890c21..3b8c764 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b24208d38a586346a3c437cd75701d99", + "content-hash": "ecfac2df9355ba0acf4ccd8e82ba27bd", "packages": [ { "name": "akeneo/api-php-client", @@ -2979,16 +2979,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.7.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "fa4c4e861e809d6a1103bd620cce63ed91aedfeb" + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/fa4c4e861e809d6a1103bd620cce63ed91aedfeb", - "reference": "fa4c4e861e809d6a1103bd620cce63ed91aedfeb", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", "shasum": "" }, "require": { @@ -2997,7 +2997,7 @@ }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^7.5@dev" + "phpunit/phpunit": "^7.5" }, "type": "library", "extra": { @@ -3043,7 +3043,7 @@ "docblock", "parser" ], - "time": "2019-08-08T18:11:40+00:00" + "time": "2019-10-01T18:55:10+00:00" }, { "name": "doctrine/instantiator", @@ -3574,22 +3574,22 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, @@ -3633,7 +3633,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "sebastian/comparator",