function it_adds_missing_product_values_from_family_on_new_product($valuesResolver, FamilyInterface $family, ProductInterface $product, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, ProductValueInterface $skuValue)
 {
     $sku->getCode()->willReturn('sku');
     $sku->getAttributeType()->willReturn('pim_catalog_identifier');
     $sku->isLocalizable()->willReturn(false);
     $sku->isScopable()->willReturn(false);
     $name->getCode()->willReturn('name');
     $name->getAttributeType()->willReturn('pim_catalog_text');
     $name->isLocalizable()->willReturn(true);
     $name->isScopable()->willReturn(false);
     $desc->getCode()->willReturn('description');
     $desc->getAttributeType()->willReturn('pim_catalog_text');
     $desc->isLocalizable()->willReturn(true);
     $desc->isScopable()->willReturn(true);
     // get expected attributes
     $product->getAttributes()->willReturn([$sku]);
     $family->getAttributes()->willReturn([$sku, $name, $desc]);
     $product->getFamily()->willReturn($family);
     // get eligible values
     $valuesResolver->resolveEligibleValues(['sku' => $sku, 'name' => $name, 'description' => $desc], null, null)->willReturn([['attribute' => 'sku', 'type' => 'pim_catalog_identifier', 'locale' => null, 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => null], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'print'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'print']]);
     // get existing values
     $skuValue->getAttribute()->willReturn($sku);
     $skuValue->getLocale()->willReturn(null);
     $skuValue->getScope()->willReturn(null);
     $product->getValues()->willReturn([$skuValue]);
     // add 6 new values : 4 desc (locales x scopes) + 2 name (locales
     $product->addValue(Argument::any())->shouldBeCalledTimes(6);
     $this->addMissingProductValues($product);
 }
 function it_renders_a_product_with_an_image($templating, ProductInterface $blender, AttributeGroupInterface $media, AttributeInterface $mainImage, ProductValueInterface $productValue, FileInfoInterface $fileInfo, CacheManager $cacheManager)
 {
     $blender->getAttributes()->willReturn([$mainImage]);
     $blender->getValue("main_image", "en_US", "ecommerce")->willReturn($productValue);
     $productValue->getMedia()->willReturn($fileInfo);
     $fileInfo->getKey()->willReturn('fookey');
     $cacheManager->isStored('fookey', 'thumbnail')->willReturn(true);
     $mainImage->getGroup()->willReturn($media);
     $media->getLabel()->willReturn('Media');
     $mainImage->getCode()->willReturn('main_image');
     $mainImage->getAttributeType()->willReturn('pim_catalog_image');
     $templating->render(self::TEMPLATE_NAME, ['product' => $blender, 'locale' => 'en_US', 'scope' => 'ecommerce', 'groupedAttributes' => ['Media' => ['main_image' => $mainImage]], 'imageAttributes' => ['main_image' => $mainImage], 'uploadDir' => '/tmp/' . DIRECTORY_SEPARATOR, 'customFont' => null])->shouldBeCalled();
     $this->render($blender, 'pdf', ['locale' => 'en_US', 'scope' => 'ecommerce']);
 }
 /**
  * Get expected attributes for the product
  *
  * @param ProductInterface $product
  *
  * @return AttributeInterface[]
  */
 protected function getExpectedAttributes(ProductInterface $product)
 {
     $attributes = [];
     $productAttributes = $product->getAttributes();
     foreach ($productAttributes as $attribute) {
         $attributes[$attribute->getCode()] = $attribute;
     }
     if ($family = $product->getFamily()) {
         foreach ($family->getAttributes() as $attribute) {
             $attributes[$attribute->getCode()] = $attribute;
         }
     }
     return $attributes;
 }
 /**
  * Get attributes to display
  *
  * @param ProductInterface $product
  * @param string           $locale
  *
  * @return AttributeInterface[]
  */
 protected function getAttributes(ProductInterface $product, $locale)
 {
     return $product->getAttributes();
 }