示例#1
0
 function it_assigns_prototype_attributes_and_options_to_product($attributeValueRepository, PrototypeInterface $prototype, ProductInterface $product, AttributeInterface $attribute, AttributeValueInterface $attributeValue, OptionInterface $option)
 {
     $prototype->getAttributes()->willReturn(array($attribute))->shouldBeCalled();
     $prototype->getOptions()->willReturn(array($option))->shouldBeCalled();
     $attributeValueRepository->createNew()->shouldBeCalled()->willReturn($attributeValue);
     $attributeValue->setAttribute($attribute)->shouldBeCalled();
     $product->addAttribute($attributeValue)->shouldBeCalled();
     $product->addOption($option)->shouldBeCalled();
     $this->build($prototype, $product);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function build(PrototypeInterface $prototype, ProductInterface $product)
 {
     foreach ($prototype->getAttributes() as $attribute) {
         $attributeValue = $this->attributeValueRepository->createNew();
         $attributeValue->setAttribute($attribute);
         $product->addAttribute($attributeValue);
     }
     foreach ($prototype->getOptions() as $option) {
         $product->addOption($option);
     }
 }