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); }
function it_should_not_reverse_transform_variable_with_variants_if_options_not_match(VariableInterface $variable, VariantInterface $variant, OptionValueInterface $optionValue) { $variable->getVariants()->willReturn([$variant]); $variant->hasOption($optionValue)->willReturn(false); $this->reverseTransform([$optionValue])->shouldReturn(null); }