function it_should_add_violation_if_variant_with_given_same_options_already_exists(ProductVariantInterface $variant, ProductVariantInterface $existingVariant, ProductInterface $variable, ProductOptionValueInterface $option, $context) { $constraint = new ProductVariantCombination(['message' => 'Variant with given options already exists']); $variant->getProduct()->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(ProductInterface $variable, ProductVariantInterface $variant, ProductOptionValueInterface $optionValue) { $variable->getVariants()->willReturn([$variant]); $variant->hasOption($optionValue)->willReturn(false); $this->reverseTransform([$optionValue])->shouldReturn(null); }