Exemplo n.º 1
0
 function it_creates_new_values_only_for_non_existing_attributes($attributeValueFactory, ArchetypeInterface $archetype, ArchetypeSubjectInterface $subject, AttributeInterface $attribute, AttributeValueInterface $attributeValue, OptionInterface $option)
 {
     $archetype->getAttributes()->willReturn(array($attribute))->shouldBeCalled();
     $archetype->getOptions()->willReturn(array($option))->shouldBeCalled();
     $attribute->getCode()->willReturn('test');
     $subject->getAttributeByCode('test')->shouldBeCalled()->willReturn($attributeValue);
     $attributeValueFactory->createNew()->shouldNotBeCalled();
     $attributeValue->setAttribute($attribute)->shouldNotBeCalled();
     $subject->getArchetype()->willReturn($archetype);
     $subject->addAttribute(Argument::any())->shouldNotBeCalled();
     $subject->addOption($option)->shouldBeCalled();
     $this->build($subject);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getOptions()
 {
     if (!$this->hasParent()) {
         return $this->options;
     }
     return new ArrayCollection(array_merge($this->parent->getOptions()->toArray(), $this->options->toArray()));
 }
Exemplo n.º 3
0
 /**
  * @param ArchetypeInterface $archetype
  * @param VariableInterface  $subject
  */
 private function createAndAssignOptions(ArchetypeInterface $archetype, VariableInterface $subject)
 {
     foreach ($archetype->getOptions() as $option) {
         $subject->addOption($option);
     }
 }