/** * Test getter/setter for code property */ public function testGetSetCode() { $this->assertEmpty($this->group->getCode()); // Change value and assert new $newCode = 'test-code'; $this->assertEntity($this->group->setCode($newCode)); $this->assertEquals($newCode, $this->group->getCode()); }
function let(ChannelManager $channelManager, ProductNormalizer $productNormalizer, PriceMappingManager $priceMappingManager, MappingCollection $categoryMapping, MappingCollection $attributeMapping, MappingCollection $storeViewMapping, ProductInterface $product, Channel $channel, Locale $localeFR, Locale $localeEN, Group $group) { $this->beConstructedWith($channelManager, $productNormalizer, $priceMappingManager, $attributeMapping); $this->globalContext = ['attributeSetId' => 0, 'magentoAttributes' => [], 'magentoAttributesOptions' => [], 'storeViewMapping' => $storeViewMapping, 'magentoStoreViews' => [['code' => 'fr_fr']], 'defaultLocale' => 'default_locale', 'website' => 'website', 'channel' => 'channel', 'categoryMapping' => $categoryMapping, 'attributeCodeMapping' => $attributeMapping, 'create' => true, 'defaultStoreView' => 'default']; $productNormalizer->getNormalizedImages($product, 'conf-group_code')->willReturn([]); $productNormalizer->getValues(Argument::cetera())->willReturn([]); $channelManager->getChannelByCode('channel')->willReturn($channel); $channel->getLocales()->willReturn([$localeEN, $localeFR]); $localeEN->getCode()->willReturn('default_locale'); $localeFR->getCode()->willReturn('fr_FR'); $channel->getCode()->willReturn('channel_code'); $storeViewMapping->getTarget('default_locale')->willReturn('default_locale'); $storeViewMapping->getTarget('fr_FR')->willReturn('fr_fr'); $group->getCode()->willReturn('group_code'); $product->getIdentifier()->willReturn('sku-000'); }
function let(ChannelManager $channelManager, ProductNormalizer $productNormalizer, PriceMappingManager $priceMappingManager, MappingCollection $categoryMapping, MappingCollection $attributeMapping, MappingCollection $storeViewMapping, ProductInterface $product, Channel $channel, Locale $localeFR, Locale $localeEN, Group $group, Attribute $attribute) { $this->beConstructedWith($channelManager, $productNormalizer, $priceMappingManager, 4); $this->globalContext = ['attributeSetId' => 0, 'magentoAttributes' => ['attribute_code' => ['attribute_id' => 42]], 'magentoAttributesOptions' => [], 'storeViewMapping' => $storeViewMapping, 'magentoStoreViews' => [['code' => 'fr_fr']], 'defaultLocale' => 'default_locale', 'website' => 'website', 'channel' => 'channel', 'categoryMapping' => $categoryMapping, 'attributeCodeMapping' => $attributeMapping, 'create' => true, 'defaultStoreView' => 'default', 'smallImageAttribute' => 'smallImageAttr', 'baseImageAttribute' => 'baseImageAttr', 'thumbnailAttribute' => 'thumbnailAttr', 'pimGrouped' => 'grouped_product_code', 'urlKey' => false, 'skuFirst' => false]; $productNormalizer->getNormalizedImages($product, 'conf-group_code', 'smallImageAttr', 'baseImageAttr', 'thumbnailAttr')->willReturn([]); $productNormalizer->getValues(Argument::cetera())->willReturn([ProductNormalizer::URL_KEY => 'my-url-key']); $channelManager->getChannelByCode('channel')->willReturn($channel); $channel->getLocales()->willReturn([$localeEN, $localeFR]); $localeEN->getCode()->willReturn('default_locale'); $localeFR->getCode()->willReturn('fr_FR'); $channel->getCode()->willReturn('channel_code'); $storeViewMapping->getTarget('default_locale')->willReturn('default_locale'); $storeViewMapping->getTarget('fr_FR')->willReturn('fr_fr'); $group->getId()->willReturn(44); $group->getCode()->willReturn('group_code'); $product->getIdentifier()->willReturn('sku-000'); $attribute->setCode('attribute_code'); $group->getAttributes()->willReturn([$attribute]); $attribute->getCode()->willReturn('attribute_code'); $attributeMapping->getTarget('attribute_code')->willReturn('attribute_code'); }
function it_normalizes_product_with_associations($filter, ProductInterface $product, AbstractAttribute $skuAttribute, AbstractProductValue $sku, Association $myCrossSell, AssociationType $crossSell, Association $myUpSell, AssociationType $upSell, Group $associatedGroup1, Group $associatedGroup2, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, AbstractProductValue $skuAssocProduct1, AbstractProductValue $skuAssocProduct2, Collection $values, Family $family, $serializer) { $family->getCode()->willReturn('shoes'); $skuAttribute->getCode()->willReturn('sku'); $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier'); $skuAttribute->isLocalizable()->willReturn(false); $skuAttribute->isScopable()->willReturn(false); $sku->getAttribute()->willReturn($skuAttribute); $sku->getData()->willReturn('sku-001'); $crossSell->getCode()->willReturn('cross_sell'); $myCrossSell->getAssociationType()->willReturn($crossSell); $myCrossSell->getGroups()->willReturn([]); $myCrossSell->getProducts()->willReturn([]); $upSell->getCode()->willReturn('up_sell'); $myUpSell->getAssociationType()->willReturn($upSell); $associatedGroup1->getCode()->willReturn('associated_group1'); $associatedGroup2->getCode()->willReturn('associated_group2'); $myUpSell->getGroups()->willReturn([$associatedGroup1, $associatedGroup2]); $skuAssocProduct1->getAttribute()->willReturn($skuAttribute); $skuAssocProduct2->getAttribute()->willReturn($skuAttribute); $skuAssocProduct1->__toString()->willReturn('sku_assoc_product1'); $skuAssocProduct2->__toString()->willReturn('sku_assoc_product2'); $associatedProduct1->getIdentifier()->willReturn($skuAssocProduct1); $associatedProduct2->getIdentifier()->willReturn($skuAssocProduct2); $myUpSell->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]); $product->getIdentifier()->willReturn($sku); $product->getFamily()->willReturn($family); $product->isEnabled()->willReturn(true); $product->getGroupCodes()->willReturn('group1,group2,variant_group_1'); $product->getCategoryCodes()->willReturn('nice shoes, converse'); $product->getAssociations()->willReturn([$myCrossSell, $myUpSell]); $product->getValues()->willReturn($values); $filter->filter(Argument::cetera())->willReturn([$sku]); $serializer->normalize($sku, 'flat', Argument::any())->willReturn(['sku' => 'sku-001']); $this->normalize($product, 'flat', [])->shouldReturn(['sku' => 'sku-001', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes, converse', 'cross_sell-groups' => '', 'cross_sell-products' => '', 'up_sell-groups' => 'associated_group1,associated_group2', 'up_sell-products' => 'sku_assoc_product1,sku_assoc_product2', 'enabled' => 1]); }
function it_normalizes_group($normalizer, Group $group) { $group->getCode()->willReturn('mongo'); $normalizer->normalize($group, 'mongodb_json', [])->willReturn(['label' => 'translations']); $this->normalize($group, 'mongodb_json', [])->shouldReturn(['code' => 'mongo', 'label' => 'translations']); }
function it_associates_only_products_in_channel_to_configurable($clientParametersRegistry, $normalizerGuesser, $groupManager, $channelManager, $productFilter, Group $group, Channel $channel, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, MagentoSoapClientParameters $clientParameters, WebserviceGuesser $webserviceGuesser, Webservice $webservice, ProductNormalizer $productNormalizer, ConfigurableNormalizer $configurableNormalizer, GroupRepository $groupRepository, StepExecution $stepExecution, EventDispatcher $eventDispatcher) { $clientParametersRegistry->getInstance(Argument::cetera())->willReturn($clientParameters); $webserviceGuesser->getWebservice($clientParameters)->willReturn($webservice); $normalizerGuesser->getProductNormalizer(Argument::cetera())->willReturn($productNormalizer); $normalizerGuesser->getConfigurableNormalizer(Argument::cetera())->willReturn($configurableNormalizer); $webservice->getStoreViewsList()->willReturn([['store_id' => '1', 'code' => 'default', 'website_id' => '1', 'group_id' => '1', 'name' => 'Default Store View', 'sort_order' => '0', 'is_active' => '1']]); $webservice->getAllAttributes()->willReturn(['name' => ['attribute_id' => '71', 'code' => 'name', 'type' => 'text', 'required' => '1', 'scope' => 'store']]); $webservice->getAllAttributesOptions()->willReturn([]); $webservice->getConfigurablesStatus([1 => ['group' => $group, 'products' => [$product1, $product2]]])->willReturn([['product_id' => '6', 'sku' => 'conf-groupCode', 'name' => 'foo', 'set' => '3', 'type' => 'configurable', 'category_ids' => ['7'], 'website_ids' => ['1']]]); $groupManager->getRepository()->willReturn($groupRepository); $groupRepository->getVariantGroupIds()->willReturn([1]); $channelManager->getChannelByCode('magento')->willReturn($channel); $channel->getId()->willReturn(3); $group->getId()->willReturn(1); $group->getProducts()->willReturn([$product1, $product2, $product3]); $group->getCode()->willReturn('groupCode'); $product1->getGroups()->willReturn([$group]); $product1->getId()->willReturn(10); $product2->getId()->willReturn(11); $product3->getId()->willReturn(12); $productFilter->apply($channel, [$product1, $product2, $product3])->willReturn([$product1, $product2]); $configurableNormalizer->normalize(['group' => $group, 'products' => [$product1, $product2]], 'MagentoArray', Argument::type('array'))->shouldBeCalled(); $this->setStepExecution($stepExecution); $this->setEventDispatcher($eventDispatcher); $this->setChannel('magento'); $this->process([$product1]); }
/** * Returns the attribute codes for a group * * @param Group $group * * @return array */ protected function getGroupAttributeCodes(Group $group) { $code = $group->getCode(); if (!isset($this->groupAttributeCodes[$code])) { $this->groupAttributeCodes[$code] = $this->getAttributeCodes($group); } return $this->groupAttributeCodes[$code]; }
/** * {@inheritDoc} */ public function getCode() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCode', array()); return parent::getCode(); }