function let(ChannelManager $channelManager, MediaManager $mediaManager, ProductValueNormalizer $productValueNormalizer, CategoryMappingManager $categoryMappingManager, AssociationTypeManager $associationTypeManager, MappingCollection $storeViewMapping, MappingCollection $categoryMapping, MappingCollection $attributeMapping, Product $product, ProductValue $productValue, ProductValue $imageValue, Channel $channel, Locale $localeFR, Locale $localeEN, Category $category) { $this->beConstructedWith($channelManager, $mediaManager, $productValueNormalizer, $categoryMappingManager, $associationTypeManager, 1, 4, 'currency', 'magento_url'); $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, 'pimGrouped' => 'pim_grouped', 'created_date' => new \DateTime(), 'updated_date' => new \DateTime(), 'defaultStoreView' => 'default', 'smallImageAttribute' => 'small_image_attribute', 'baseImageAttribute' => 'image_attribute', 'thumbnailAttribute' => 'image_attribute']; $attributeMapping->getTarget('visibility')->willReturn('visibility'); $attributeMapping->getTarget('created_at')->willReturn('created_at'); $attributeMapping->getTarget('updated_at')->willReturn('updated_at'); $attributeMapping->getTarget('status')->willReturn('status'); $attributeMapping->getTarget('categories')->willReturn('categories'); $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'); $channel->getCategory()->willReturn($category); $product->getCategories()->willReturn([$category]); $product->getIdentifier()->willReturn('sku-000'); $product->getCreated()->willReturn($this->globalContext['created_date']); $product->getUpdated()->willReturn($this->globalContext['updated_date']); $product->getValues()->willReturn(new ArrayCollection([$productValue, $imageValue])); $storeViewMapping->getTarget('default_locale')->willReturn('default_locale'); $storeViewMapping->getTarget('fr_FR')->willReturn('fr_fr'); $categoryMappingManager->getIdFromCategory($category, 'magento_url', $categoryMapping)->willReturn(2); $productValueNormalizer->normalize($productValue, Argument::cetera())->willReturn(['value' => 'productValueNormalized']); $productValueNormalizer->normalize($imageValue, Argument::cetera())->willReturn(null); }
/** * Check product values * * @param Product $product the product * @param array $valueKeys the expected value keys (attCode + locale + scope) * * @return boolean */ protected function assertValues($product, $valueKeys) { $nbValues = count($valueKeys); $values = $product->getValues(); $this->assertEquals(count($values), $nbValues); foreach ($values as $value) { $key = $value->getAttribute()->getCode() . $value->getLocale() . $value->getScope(); $this->assertTrue(in_array($key, $valueKeys)); } }
/** * {@inheritDoc} */ public function getValues() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValues', array()); return parent::getValues(); }