function it_returns_well_formatted_actions_for_batch_job(AttributeInterface $attrColor, AttributeInterface $attrSize, ChannelInterface $channelMobile, ChannelInterface $channelEcommerce, AttributeRequirementInterface $colorMobileRequirement, AttributeRequirementInterface $colorEcommerceRequirement, AttributeRequirementInterface $sizeEcommerceRequirement)
 {
     $attrColor->getCode()->willReturn('color');
     $attrSize->getCode()->willReturn('size');
     $channelMobile->getCode()->willReturn('mobile');
     $channelEcommerce->getCode()->willReturn('ecommerce');
     $colorMobileRequirement->getAttribute()->willReturn($attrColor);
     $colorEcommerceRequirement->getAttribute()->willReturn($attrColor);
     $sizeEcommerceRequirement->getAttribute()->willReturn($attrSize);
     $colorMobileRequirement->getChannel()->willReturn($channelMobile);
     $colorEcommerceRequirement->getChannel()->willReturn($channelEcommerce);
     $sizeEcommerceRequirement->getChannel()->willReturn($channelEcommerce);
     $colorMobileRequirement->isRequired()->willReturn(false);
     $colorEcommerceRequirement->isRequired()->willReturn(true);
     $sizeEcommerceRequirement->isRequired()->willReturn(true);
     $colorMobileRequirement->getAttributeCode()->willReturn('color');
     $colorEcommerceRequirement->getAttributeCode()->willReturn('color');
     $sizeEcommerceRequirement->getAttributeCode()->willReturn('size');
     $colorMobileRequirement->getChannelCode()->willReturn('mobile');
     $colorEcommerceRequirement->getChannelCode()->willReturn('ecommerce');
     $sizeEcommerceRequirement->getChannelCode()->willReturn('ecommerce');
     $this->addAttributeRequirement($colorMobileRequirement);
     $this->addAttributeRequirement($colorEcommerceRequirement);
     $this->addAttributeRequirement($sizeEcommerceRequirement);
     $this->getActions()->shouldReturn([['attribute_code' => 'color', 'channel_code' => 'mobile', 'is_required' => false], ['attribute_code' => 'color', 'channel_code' => 'ecommerce', 'is_required' => true], ['attribute_code' => 'size', 'channel_code' => 'ecommerce', 'is_required' => true]]);
 }
 function it_does_not_validate_families_with_missing_identifier_requirements($attributeRepository, $channelRepository, $context, $minimumRequirements, FamilyInterface $family, AttributeRequirementInterface $requirementEcommerce, AttributeRequirementInterface $requirementMobile, ConstraintViolationBuilderInterface $violation)
 {
     $family->getAttributeRequirements()->willReturn([$requirementEcommerce, $requirementMobile]);
     $attributeRepository->getIdentifierCode()->willReturn('sku');
     $requirementEcommerce->getAttributeCode()->willReturn('sku');
     $requirementEcommerce->getChannelCode()->willReturn('ecommerce');
     $requirementMobile->getAttributeCode()->willReturn('sku');
     $requirementMobile->getChannelCode()->willReturn('mobile');
     $channelRepository->getChannelCodes()->willReturn(['ecommerce', 'mobile', 'print']);
     $family->getCode()->willReturn('familyCode');
     $context->buildViolation(Argument::any(), Argument::any())->willReturn($violation)->shouldBeCalled();
     $this->validate($family, $minimumRequirements);
 }
 function it_creates_a_family($attributeRepository, $channelManager, $factory, AttributeInterface $identifierAttribute, ChannelInterface $printChannel, ChannelInterface $ecommerceChannel, AttributeRequirementInterface $printRequirement, AttributeRequirementInterface $ecommerceRequirement)
 {
     $attributeRepository->getIdentifier()->willReturn($identifierAttribute)->shouldBeCalled();
     $printRequirement->setFamily(Argument::any())->willReturn(null);
     $printRequirement->getAttributeCode()->willReturn('anyCode');
     $printRequirement->getChannelCode()->willReturn('print');
     $ecommerceRequirement->setFamily(Argument::any())->willReturn(null);
     $ecommerceRequirement->getAttributeCode()->willReturn('anyCode');
     $ecommerceRequirement->getChannelCode()->willReturn('ecommerce');
     $channelManager->getChannels()->willReturn([$printChannel, $ecommerceChannel])->shouldBeCalled();
     $factory->createAttributeRequirement($identifierAttribute, $printChannel, true)->willReturn($printRequirement)->shouldBeCalled();
     $factory->createAttributeRequirement($identifierAttribute, $ecommerceChannel, true)->willReturn($ecommerceRequirement)->shouldBeCalled();
     $family = $this->createFamily();
     $family->shouldBeAnInstanceOf('Pim\\Component\\Catalog\\Model\\FamilyInterface');
     $family->getAttributes()->shouldHaveCount(1);
     $family->getAttributes()->first()->shouldBeEqualTo($identifierAttribute);
     $family->getAttributeRequirements()->shouldHaveCount(2);
     $family->getAttributeRequirements()->shouldBeEqualTo(['anyCode_print' => $printRequirement, 'anyCode_ecommerce' => $ecommerceRequirement]);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function getAttributeRequirementKey(AttributeRequirementInterface $requirement)
 {
     return sprintf('%s_%s', $requirement->getAttributeCode(), $requirement->getChannelCode());
 }