function it_should_add_violation_if_variant_with_given_same_options_already_exists(VariantInterface $variant, VariantInterface $existingVariant, VariableInterface $variable, OptionValueInterface $option, $context)
 {
     $constraint = new VariantCombination(array('message' => 'Variant with given options already exists'));
     $variant->isMaster()->willReturn(false);
     $variant->getObject()->willReturn($variable);
     $variant->getOptions()->willReturn(array($option));
     $existingVariant->hasOption($option)->willReturn(true);
     $variable->hasVariants()->willReturn(true);
     $variable->hasOptions()->willReturn(true);
     $variable->getVariants()->willReturn(array($existingVariant));
     $context->addViolation('Variant with given options already exists', Argument::any())->shouldBeCalled();
     $this->validate($variant, $constraint);
 }
Exemplo n.º 2
0
 function it_throws_exception_if_trying_to_inherit_values_from_non_master_variant(VariantInterface $variant)
 {
     $variant->isMaster()->willReturn(false);
     $this->shouldThrow('InvalidArgumentException')->duringSetDefaults($variant);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function setDefaults(VariantInterface $masterVariant)
 {
     if (!$masterVariant->isMaster()) {
         throw new \InvalidArgumentException('Cannot inherit values from non master variant.');
     }
     if ($this->isMaster()) {
         throw new \LogicException('Master variant cannot inherit from another master variant.');
     }
 }