function it_copies_multi_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue, AttributeOptionInterface $attributeOption) { $fromLocale = 'fr_FR'; $toLocale = 'fr_FR'; $toScope = 'mobile'; $fromScope = 'mobile'; $fromAttribute->getCode()->willReturn('fromAttributeCode'); $toAttribute->getCode()->willReturn('toAttributeCode'); $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled(); $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled(); $fromProductValue->getOptions()->willReturn([$attributeOption])->shouldBeCalled(3); $toProductValue->getOptions()->willReturn([$attributeOption]); $toProductValue->removeOption($attributeOption)->shouldBeCalled(); $toProductValue->addOption($attributeOption)->shouldBeCalled(); $product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null); $product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null); $product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue); $products = [$product1, $product2, $product3, $product4]; foreach ($products as $product) { $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]); } }
function it_copies_a_price_collection_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue, ProductPriceInterface $price) { $fromLocale = 'fr_FR'; $toLocale = 'fr_FR'; $toScope = 'mobile'; $fromScope = 'mobile'; $fromAttribute->getCode()->willReturn('fromAttributeCode'); $toAttribute->getCode()->willReturn('toAttributeCode'); $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled(); $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled(); $fromProductValue->getData()->willReturn([$price]); $price->getCurrency()->willReturn('USD'); $price->getData()->willReturn(123); $product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null); $product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null); $product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue); $builder->addPriceForCurrencyWithData($toProductValue, 'USD', 123)->shouldBeCalled(); $products = [$product1, $product2, $product3, $product4]; foreach ($products as $product) { $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]); } }
/** * Copy single value * * @param ProductInterface $product * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string $fromLocale * @param string $toLocale * @param string $fromScope * @param string $toScope */ protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope); } $this->copyOptions($fromValue, $toValue); } }
function it_adds_a_violation_when_validates_a_product_with_missing_value_for_an_axe_of_its_variant_group($context, ProductInterface $product, GroupInterface $tShirtVariantGroup, AttributeInterface $sizeAttribute, AttributeInterface $colorAttribute, ProductValueInterface $sizeValue, ProductValueInterface $identifierValue, HasVariantAxes $constraint, ConstraintViolationBuilderInterface $violation) { $tShirtVariantGroup->getCode()->willReturn('tshirt'); $tShirtVariantGroup->getAxisAttributes()->willReturn([$sizeAttribute, $colorAttribute]); $sizeAttribute->getCode()->willReturn('size'); $colorAttribute->getCode()->willReturn('color'); $product->getIdentifier()->willReturn($identifierValue); $product->getVariantGroup()->willReturn($tShirtVariantGroup); $product->getValue('size')->willReturn($sizeValue); $product->getValue('color')->willReturn(null); $sizeValue->getData()->willReturn('XL'); $context->buildViolation('The product "%product%" is in the variant group "%variant%" but it misses the following axes: %axes%.', ['%product%' => $identifierValue, '%variant%' => 'tshirt', '%axes%' => 'color'])->shouldBeCalled()->willReturn($violation); $this->validate($product, $constraint); }
function it_allows_setting_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value) { $attribute->getCode()->willReturn('choice'); $product->getValue('choice', null, null)->shouldBeCalled()->willReturn($value); $value->setOption(null)->shouldBeCalled(); $this->setValue([$product], $attribute, null); }
function it_allows_setting_attribute_data_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value) { $attribute->getCode()->willReturn('choice'); $product->getValue('choice', 'fr_FR', 'mobile')->shouldBeCalled()->willReturn($value); $value->setOption(null)->shouldBeCalled(); $this->setAttributeData($product, $attribute, null, ['locale' => 'fr_FR', 'scope' => 'mobile']); }
function it_creates_and_sets_geolocation_to_product_value($productBuilder, ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value) { $attribute->getCode()->shouldBeCalled()->willReturn('geolocation'); $product->getValue('geolocation', 'FR', 'master')->shouldBeCalled()->willReturn(null); $productBuilder->addProductValue($product, $attribute, 'FR', 'master')->shouldBeCalled()->willReturn($value); $value->setData(Argument::type('CleverAge\\Bundle\\GeolocAttributeBundle\\Model\\Geolocation'))->shouldBeCalled(); $this->setValue([$product], $attribute, ['latitude' => 12, 'longitude' => 12], 'FR', 'master'); }
/** * Set media in the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param FileInfoInterface|null $fileInfo * @param string|null $locale * @param string|null $scope */ protected function setMedia(ProductInterface $product, AttributeInterface $attribute, FileInfoInterface $fileInfo = null, $locale = null, $scope = null) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setMedia($fileInfo); }
/** * @param ProductInterface $product * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string $fromLocale * @param string $toLocale * @param string $fromScope * @param string $toScope */ protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $fromData = $fromValue->getData(); $toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope); } if (null === ($metric = $toValue->getMetric())) { $metric = $this->metricFactory->createMetric($fromData->getFamily()); } $metric->setUnit($fromData->getUnit()); $metric->setData($fromData->getData()); $toValue->setMetric($metric); } }
/** * Set option into the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param AttributeOptionInterface|null $option * @param string|null $locale * @param string|null $scope */ protected function setOption(ProductInterface $product, AttributeInterface $attribute, AttributeOptionInterface $option = null, $locale = null, $scope = null) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setOption($option); }
/** * Set data into product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param mixed $data * @param string $locale * @param string $scope */ protected function setData(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setData($data); }
/** * Returns the image path for an attribute of a product. If no image is found, returns null. * * @param ProductInterface $product * @param AttributeInterface $attribute * @param string $locale * @param string $scope * * @return string|null */ public function getImagePath(ProductInterface $product, AttributeInterface $attribute, $locale, $scope) { $productValue = $product->getValue($attribute->getCode(), $locale, $scope); $path = null; if (null !== $productValue->getMedia() && null !== $productValue->getMedia()->getKey()) { $path = sprintf('media/cache/thumbnail/%s', $productValue->getMedia()->getKey()); } return $path; }
function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value) { $this->beConstructedWith($productRepository, $uniqueValuesSet); $product->getValue('unique_attribute')->willReturn($value); $form->getData()->willReturn($product); $context->getPropertyPath()->willReturn(self::PROPERTY_PATH); $context->getRoot()->willReturn($form); $this->initialize($context); }
function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value) { $this->beConstructedWith($productManager); $product->getValue('sku')->willReturn($value); $form->getData()->willReturn($product); $context->getPropertyPath()->willReturn(self::PROPERTY_PATH); $context->getRoot()->willReturn($form); $this->initialize($context); }
/** * Adds options into the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param array $attributeOptions * @param string $locale * @param string $scope */ protected function addOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } foreach ($attributeOptions as $attributeOption) { $value->addOption($attributeOption); } }
/** * Remove prices from product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param mixed $data * @param string $locale * @param string $scope */ protected function removePrices(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope) { $productValue = $product->getValue($attribute->getCode(), $locale, $scope); if (null !== $productValue) { foreach ($data as $price) { $priceToRemove = $productValue->getPrice($price['currency']); $productValue->removePrice($priceToRemove); } } }
function it_sets_null_value_when_receiving_empty_string(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = ''; $attribute->getCode()->willReturn('attributeCode'); $productValue->setData(null)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $this->setAttributeData($product1, $attribute, $data, ['locale' => $locale, 'scope' => $scope]); }
/** * Get missing axis codes of a product given a variant group * * @param ProductInterface $product * @param GroupInterface $variantGroup * * @return array */ protected function getMissingAxisCodes(ProductInterface $product, GroupInterface $variantGroup) { $missingAxisCodes = []; foreach ($variantGroup->getAxisAttributes() as $attribute) { $value = $product->getValue($attribute->getCode()); if (null === $value || null === $value->getData()) { $missingAxisCodes[] = $attribute->getCode(); } } return $missingAxisCodes; }
/** * Set reference data into the product value * * @param AttributeInterface $attribute * @param ProductInterface $product * @param ReferenceDataInterface|null $referenceData * @param string|null $locale * @param string|null $scope * * @throws \LogicException */ protected function setReferenceData(AttributeInterface $attribute, ProductInterface $product, $referenceData = null, $locale = null, $scope = null) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $setMethod = MethodNameGuesser::guess('set', $attribute->getReferenceDataName(), true); if (!method_exists($value, $setMethod)) { throw new \LogicException(sprintf('ProductValue method "%s" is not implemented', $setMethod)); } $value->{$setMethod}($referenceData); }
/** * Copy single value * * @param ProductInterface $fromProduct * @param ProductInterface $toProduct * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string $fromLocale * @param string $toLocale * @param string $fromScope * @param string $toScope */ protected function copySingleValue(ProductInterface $fromProduct, ProductInterface $toProduct, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $fromProduct->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $toValue = $toProduct->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($toProduct, $toAttribute, $toLocale, $toScope); } $this->removeReferenceDataCollection($toValue, $toAttribute); $this->copyReferenceDataCollection($fromValue, $toValue, $fromAttribute, $toAttribute); } }
/** * @param AttributeInterface $attribute * @param ProductInterface $product * @param array $data * @param string|null $locale * @param string|null $scope */ protected function setGelocation(AttributeInterface $attribute, $product, $data, $locale, $scope) { /** @var ProductValue $value */ $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $productGeolocation = new Geolocation(); $productGeolocation->setLatitude($data['latitude']); $productGeolocation->setLongitude($data['longitude']); $value->setData($productGeolocation); }
/** * @param ProductInterface $product * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string $fromLocale * @param string $toLocale * @param string $fromScope * @param string $toScope */ protected function copySingleValue(ProductInterface $product, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $product->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $toValue = $product->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($product, $toAttribute, $toLocale, $toScope); } $mediaHasFileName = false; if (null !== $fromValue->getMedia()) { $originalFileName = $fromValue->getMedia()->getOriginalFilename(); if (!empty($originalFileName)) { $mediaHasFileName = true; } } if ($mediaHasFileName) { $this->duplicateMedia($product, $fromValue, $toValue); } else { $this->deleteMedia($toValue); } } }
/** * @param ProductInterface $fromProduct * @param ProductInterface $toProduct * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string|null $fromLocale * @param string|null $toLocale * @param string|null $fromScope * @param string|null $toScope */ protected function copySingleValue(ProductInterface $fromProduct, ProductInterface $toProduct, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $fromProduct->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $toValue = $toProduct->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($toProduct, $toAttribute, $toLocale, $toScope); } $fromDataGetter = $this->getValueMethodName($fromValue, $fromAttribute, 'get'); $toDataSetter = $this->getValueMethodName($toValue, $toAttribute, 'set'); $toValue->{$toDataSetter}($fromValue->{$fromDataGetter}()); } }
/** * Set the data into the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param mixed $data * @param string $unit * @param string $locale * @param string $scope */ protected function setData(ProductInterface $product, AttributeInterface $attribute, $data, $unit, $locale, $scope) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } if (null === ($metric = $value->getMetric())) { $metric = $this->metricFactory->createMetric($attribute->getMetricFamily()); } $value->setMetric($metric); $metric->setUnit($unit); $metric->setData($data); }
function it_copies_a_metric_value_to_a_product_value($builder, $metricFactory, $attrValidatorHelper, MetricInterface $metric, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue, ProductValue $toProductValue2) { $fromLocale = 'fr_FR'; $toLocale = 'fr_FR'; $toScope = 'mobile'; $fromScope = 'mobile'; $fromAttribute->getCode()->willReturn('fromAttributeCode'); $toAttribute->getCode()->willReturn('toAttributeCode'); $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled(); $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled(); $attrValidatorHelper->validateUnitFamilies(Argument::cetera())->shouldBeCalled(); $fromProductValue->getData()->willReturn($metric); $toProductValue->setMetric($metric)->shouldBeCalledTimes(2); $toProductValue->getData()->willReturn($metric); $toProductValue->getMetric()->willReturn($metric); $toProductValue2->setMetric($metric)->shouldBeCalledTimes(1); $toProductValue2->getData()->willReturn($metric); $toProductValue2->getMetric()->willReturn(null); $metric->getFamily()->shouldBeCalled()->willReturn('Weight'); $metric->getData()->shouldBeCalled()->willReturn(123); $metric->getUnit()->shouldBeCalled()->willReturn('kg'); $metric->setData(123)->shouldBeCalled(); $metric->setUnit('kg')->shouldBeCalled(); $product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null); $product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null); $product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue2); $metricFactory->createMetric('Weight')->shouldBeCalledTimes(1)->willReturn($metric); $builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue); $products = [$product1, $product2, $product3, $product4]; foreach ($products as $product) { $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]); } }
function it_sets_date_value_to_a_product_value_with_datetime(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValueInterface $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = new \DateTime(); $attribute->getCode()->willReturn('attributeCode'); $productValue->setData(Argument::type('\\Datetime'))->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->willReturn($productValue); $products = [$product1, $product2, $product3]; $this->setValue($products, $attribute, $data, $locale, $scope); }
function it_sets_boolean_value_to_a_product_value(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = true; $attribute->getCode()->willReturn('attributeCode'); $productValue->setData($data)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->willReturn($productValue); $products = [$product1, $product2, $product3]; $this->setValue($products, $attribute, $data, $locale, $scope); }
function it_renders_a_product_with_an_image($templating, ProductInterface $blender, AttributeGroupInterface $media, AttributeInterface $mainImage, ProductValueInterface $productValue, FileInfoInterface $fileInfo, CacheManager $cacheManager) { $path = realpath(__DIR__ . '/../../../../../features/Context/fixtures/'); $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' => $path . DIRECTORY_SEPARATOR, 'customFont' => null])->shouldBeCalled(); $this->render($blender, 'pdf', ['locale' => 'en_US', 'scope' => 'ecommerce']); }
function it_sets_attribute_data_text_value_to_a_product_value(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = 'data'; $attribute->getCode()->willReturn('attributeCode'); $productValue->setData($data)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->willReturn($productValue); $this->setAttributeData($product1, $attribute, $data, ['locale' => $locale, 'scope' => $scope]); $this->setAttributeData($product2, $attribute, $data, ['locale' => $locale, 'scope' => $scope]); $this->setAttributeData($product3, $attribute, $data, ['locale' => $locale, 'scope' => $scope]); }
function it_sets_a_price_collection_value_to_a_product_value($builder, $currencyManager, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValue $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = [['data' => 123.2, 'currency' => 'EUR']]; $currencyManager->getActiveCodes()->willReturn(['EUR', 'USD']); $attribute->getCode()->willReturn('attributeCode'); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->willReturn($productValue); $products = [$product1, $product2, $product3]; $builder->addPriceForCurrencyWithData($productValue, 'EUR', 123.2)->shouldBeCalled(); $this->setValue($products, $attribute, $data, $locale, $scope); }