Exemplo n.º 1
0
 function it_should_remove_value(OptionValueInterface $value)
 {
     $value->setOption($this)->shouldBeCalled();
     $this->addValue($value);
     $this->hasValue($value)->shouldReturn(true);
     $value->setOption(null)->shouldBeCalled();
     $this->removeValue($value);
     $this->hasValue($value)->shouldReturn(false);
 }
 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(['message' => 'Variant with given options already exists']);
     $variant->getObject()->willReturn($variable);
     $variant->getOptions()->willReturn(new ArrayCollection([$option->getWrappedObject()]));
     $existingVariant->hasOption($option)->willReturn(true);
     $variable->hasVariants()->willReturn(true);
     $variable->hasOptions()->willReturn(true);
     $variable->getVariants()->willReturn([$existingVariant]);
     $context->addViolation('Variant with given options already exists', Argument::any())->shouldBeCalled();
     $this->validate($variant, $constraint);
 }