コード例 #1
0
 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]]);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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
ファイル: Family.php プロジェクト: userz58/pim-community-dev
 /**
  * {@inheritdoc}
  */
 public function getAttributeRequirementKey(AttributeRequirementInterface $requirement)
 {
     return sprintf('%s_%s', $requirement->getAttributeCode(), $requirement->getChannelCode());
 }
コード例 #5
0
 public function it_should_not_remove_identifier_requirements_when_other_requirements_are_provided($attrRequiFactory, $channelRepository, FamilyInterface $family, AttributeRepositoryInterface $attributeRepository, AttributeInterface $skuAttribute, AttributeInterface $nameAttribute, AttributeInterface $descAttribute, AttributeRequirementInterface $skuMobileRqrmt, AttributeRequirementInterface $skuPrintRqrmt, AttributeRequirementInterface $namePrintRqrmt, AttributeRequirementInterface $descPrintRqrmt, ChannelInterface $mobileChannel, ChannelInterface $printChannel)
 {
     $values = ['code' => 'mycode', 'requirements' => ['print' => ['name', 'description']]];
     $family->getAttributeRequirements()->willReturn([$skuMobileRqrmt, $skuPrintRqrmt]);
     $family->getId()->willReturn(42);
     $skuMobileRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuPrintRqrmt->getAttribute()->willReturn($skuAttribute);
     $skuMobileRqrmt->getChannelCode()->willReturn('mobile');
     $skuPrintRqrmt->getChannelCode()->willReturn('print');
     $skuAttribute->getAttributeType()->willReturn(AttributeTypes::IDENTIFIER);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attributeRepository->findOneByIdentifier('name')->willReturn($nameAttribute);
     $attributeRepository->findOneByIdentifier('description')->willReturn($descAttribute);
     $attrRequiFactory->createAttributeRequirement($nameAttribute, $printChannel, true)->willReturn($namePrintRqrmt);
     $attrRequiFactory->createAttributeRequirement($descAttribute, $printChannel, true)->willReturn($descPrintRqrmt);
     $namePrintRqrmt->getAttribute()->willReturn($nameAttribute);
     $descPrintRqrmt->getAttribute()->willReturn($descAttribute);
     $channelRepository->getChannelCodes()->willReturn(['mobile', 'print']);
     $channelRepository->findOneByIdentifier('mobile')->willReturn($mobileChannel);
     $channelRepository->findOneByIdentifier('print')->willReturn($printChannel);
     $attributeRepository->getIdentifier()->willReturn($skuAttribute);
     $family->setCode('mycode')->shouldBeCalled();
     $family->setAttributeRequirements([$skuMobileRqrmt, $skuPrintRqrmt, $namePrintRqrmt, $descPrintRqrmt])->shouldBeCalled();
     $this->update($family, $values, []);
 }