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]);
     }
 }
 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]);
 }
 function it_sets_non_number_value_to_a_product_attribute_data_value(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue)
 {
     $locale = 'fr_FR';
     $scope = 'mobile';
     $data = 'foo';
     $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_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_non_numeric_attribute_data_to_a_product_value(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, $factory, MetricInterface $metric, ProductValue $productValue)
 {
     $locale = 'fr_FR';
     $scope = 'mobile';
     $data = ['data' => 'foo', 'unit' => 'KILOGRAM'];
     $attribute->getCode()->willReturn('attributeCode');
     $attribute->getMetricFamily()->willReturn('Weight');
     $productValue->getMetric()->willReturn(null);
     $productValue->setMetric($metric)->shouldBeCalled();
     $metric->setUnit('KILOGRAM')->shouldBeCalled();
     $metric->setData($data['data'])->shouldBeCalled();
     $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue);
     $factory->createMetric('Weight')->shouldBeCalledTimes(3)->willReturn($metric);
     $product1->getValue('attributeCode', $locale, $scope)->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]);
 }
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->fabrics = new ArrayCollection();
     $this->myNewField = rand();
 }
 function it_copies_media_value_to_a_product_value($attrValidatorHelper, $builder, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValue $fromProductValue, ProductValue $toProductValue)
 {
     $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(['originalFilename' => 'akeneo', 'filePath' => 'path/to/file']);
     $toProductValue->setData(['originalFilename' => 'akeneo', 'filePath' => 'path/to/file'])->shouldBeCalledTimes(3);
     $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]);
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->fabrics = new ArrayCollection();
     $this->brands = new ArrayCollection();
 }