function it_updates_a_family($attrRequiFactory, $channelRepository, FamilyTranslation $translation, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $attribute1, AttributeInterface $attribute2, AttributeInterface $attribute3, AttributeInterface $attribute4, AttributeRequirementInterface $attributeRequirement1, AttributeRequirementInterface $attributeRequirement2, AttributeRequirementInterface $attributeRequirement3, AttributeRequirementInterface $attributeRequirement4, AttributeRequirementInterface $attributeRequirement5, ChannelInterface $channel1, ChannelInterface $channel2, FamilyInterface $family)
 {
     $values = ['code' => 'mycode', 'attributes' => ['sku', 'name', 'description', 'price'], 'attribute_as_label' => 'name', 'requirements' => ['mobile' => ['sku', 'name'], 'print' => ['sku', 'name', 'description']], 'labels' => ['fr_FR' => 'Moniteurs', 'en_US' => 'PC Monitors']];
     $attributeRepository->findOneByIdentifier('sku')->willReturn($attribute1);
     $attributeRepository->findOneByIdentifier('name')->willReturn($attribute2);
     $attributeRepository->findOneByIdentifier('description')->willReturn($attribute3);
     $attributeRepository->findOneByIdentifier('price')->willReturn($attribute4);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($channel1);
     $channelRepository->findOneByIdentifier('print')->willReturn($channel2);
     $attrRequiFactory->createAttributeRequirement($attribute1, $channel1, true)->willReturn($attributeRequirement1);
     $attrRequiFactory->createAttributeRequirement($attribute2, $channel1, true)->willReturn($attributeRequirement2);
     $attrRequiFactory->createAttributeRequirement($attribute1, $channel2, true)->willReturn($attributeRequirement3);
     $attrRequiFactory->createAttributeRequirement($attribute2, $channel2, true)->willReturn($attributeRequirement4);
     $attrRequiFactory->createAttributeRequirement($attribute3, $channel2, true)->willReturn($attributeRequirement5);
     $family->setAttributeRequirements([$attributeRequirement1, $attributeRequirement2, $attributeRequirement3, $attributeRequirement4, $attributeRequirement5])->shouldBeCalled();
     $family->setCode('mycode')->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute2)->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->setLocale('en_US')->shouldBeCalled();
     $family->setLocale('fr_FR')->shouldBeCalled();
     $family->getTranslation()->willReturn($translation);
     $translation->setLabel('label en us');
     $translation->setLabel('label fr fr');
     $family->addAttribute($attribute1)->shouldBeCalled();
     $family->addAttribute($attribute2)->shouldBeCalled();
     $family->addAttribute($attribute3)->shouldBeCalled();
     $family->addAttribute($attribute4)->shouldBeCalled();
     $family->setAttributeAsLabel($attribute2)->shouldBeCalled();
     $this->update($family, $values, []);
 }
 function it_updates_a_family($attrRequiFactory, $channelRepository, FamilyTranslation $translation, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $skuAttribute, AttributeInterface $nameAttribute, AttributeInterface $descAttribute, AttributeInterface $priceAttribute, AttributeRequirementInterface $skuMobileRqrmt, AttributeRequirementInterface $nameMobileRqrmt, AttributeRequirementInterface $skuPrintRqrmt, AttributeRequirementInterface $namePrintRqrmt, AttributeRequirementInterface $descPrintRqrmt, ChannelInterface $mobileChannel, ChannelInterface $printChannel)
 {
     $values = ['code' => 'mycode', 'attributes' => ['sku', 'name', 'description', 'price'], 'attribute_as_label' => 'name', 'requirements' => ['mobile' => ['sku', 'name'], 'print' => ['name', 'description']], 'labels' => ['fr_FR' => 'Moniteurs', 'en_US' => 'PC Monitors']];
     $family->getAttributeRequirements()->willReturn([$skuMobileRqrmt, $skuPrintRqrmt]);
     $family->getAttributes()->willReturn([$skuAttribute, $nameAttribute, $descAttribute, $priceAttribute]);
     $family->removeAttribute($nameAttribute)->shouldBeCalled();
     $family->removeAttribute($priceAttribute)->shouldBeCalled();
     $family->removeAttribute($descAttribute)->shouldBeCalled();
     $family->getId()->willReturn(42);
     $skuAttribute->getId()->willReturn(1);
     $nameAttribute->getId()->willReturn(2);
     $descAttribute->getId()->willReturn(3);
     $priceAttribute->getId()->willReturn(4);
     $skuMobileRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuMobileRqrmt->getChannelCode()->willReturn('mobile');
     $skuPrintRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuPrintRqrmt->getChannelCode()->willReturn('print');
     $attributeRepository->findOneByIdentifier('sku')->willReturn($skuAttribute);
     $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute);
     $attributeRepository->findOneByIdentifier('description')->willReturn($descAttribute);
     $attributeRepository->findOneByIdentifier('price')->willReturn($priceAttribute);
     $attributeRepository->getIdentifier()->willReturn($skuAttribute);
     $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $nameAttribute->getAttributeType()->willReturn('pim_catalog_text');
     $descAttribute->getAttributeType()->willReturn('pim_catalog_textarea');
     $priceAttribute->getAttributeType()->willReturn('pim_catalog_price_collection');
     $channelRepository->getChannelCodes()->willReturn(['mobile', 'print']);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $mobileChannel, true)->willReturn($nameMobileRqrmt);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $printChannel, true)->willReturn($namePrintRqrmt);
     $attrRequiFactory->createAttributeRequirement($descAttribute, $printChannel, true)->willReturn($descPrintRqrmt);
     $nameMobileRqrmt->getAttribute()->willReturn($nameAttribute);
     $namePrintRqrmt->getAttribute()->willReturn($nameAttribute);
     $descPrintRqrmt->getAttribute()->willReturn($descAttribute);
     $family->setAttributeRequirements([$skuMobileRqrmt, $skuPrintRqrmt, $nameMobileRqrmt, $namePrintRqrmt, $descPrintRqrmt])->shouldBeCalled();
     $family->setCode('mycode')->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($nameAttribute)->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->setLocale('en_US')->shouldBeCalled();
     $family->setLocale('fr_FR')->shouldBeCalled();
     $family->getTranslation()->willReturn($translation);
     $translation->setLabel('label en us');
     $translation->setLabel('label fr fr');
     $family->addAttribute($skuAttribute)->shouldBeCalled();
     $family->addAttribute($nameAttribute)->shouldBeCalled();
     $family->addAttribute($descAttribute)->shouldBeCalled();
     $family->addAttribute($priceAttribute)->shouldBeCalled();
     $family->setAttributeAsLabel($nameAttribute)->shouldBeCalled();
     $this->update($family, $values, []);
 }
Пример #3
0
 /**
  * @param FamilyInterface $family
  * @param array           $data
  */
 protected function setLabels(FamilyInterface $family, array $data)
 {
     foreach ($data as $localeCode => $label) {
         $family->setLocale($localeCode);
         $translation = $family->getTranslation();
         $translation->setLabel($label);
     }
 }