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);
 }
 /**
  * @param VariantInterface  $variant
  * @param VariableInterface $variable
  *
  * @return bool
  */
 private function matches(VariantInterface $variant, VariableInterface $variable)
 {
     foreach ($variable->getVariants() as $existingVariant) {
         if ($variant === $existingVariant) {
             continue;
         }
         $matches = true;
         if (!$variant->getOptions()->count()) {
             continue;
         }
         foreach ($variant->getOptions() as $option) {
             if (!$existingVariant->hasOption($option)) {
                 $matches = false;
             }
         }
         if ($matches) {
             return true;
         }
     }
     return false;
 }
 function it_should_transform_variant_into_variant_options(VariantInterface $variant)
 {
     $variant->getOptions()->willReturn([]);
     $this->transform($variant)->shouldReturn([]);
 }