function it_copies_simple_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValueInterface $fromProductValue, ProductValueInterface $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->getData()->willReturn($attributeOption); $toProductValue->setOption($attributeOption)->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]); } }
function it_sets_simpleselect_option_to_a_product_value($builder, $attrOptionRepository, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption) { $locale = 'fr_FR'; $scope = 'mobile'; $attribute->getCode()->willReturn('attributeCode'); $attributeOption->getCode()->willReturn('attributeOptionCode'); $attrOptionRepository->findOneBy(['code' => 'attributeOptionCode', 'attribute' => $attribute])->shouldBeCalledTimes(1)->willReturn($attributeOption); $productValue->setOption($attributeOption)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $this->setValue([$product1, $product2, $product3], $attribute, 'attributeOptionCode', $locale, $scope); }
function it_sets_attribute_data_simpleselect_option_to_a_product_value($builder, $attrOptionRepository, AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption) { $locale = 'fr_FR'; $scope = 'mobile'; $attribute->getCode()->willReturn('attributeCode'); $attributeOption->getCode()->willReturn('red'); $attrOptionRepository->findOneByIdentifier('attributeCode.red')->shouldBeCalledTimes(3)->willReturn($attributeOption); $productValue->setOption($attributeOption)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $product2->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn(null); $product3->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $this->setAttributeData($product1, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]); $this->setAttributeData($product2, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]); $this->setAttributeData($product3, $attribute, 'red', ['locale' => $locale, 'scope' => $scope]); }