/**
  * Don't allow creating variant group type if one already exists
  *
  * @param GroupTypeInterface $groupType
  * @param Constraint         $constraint
  */
 public function validate($groupType, Constraint $constraint)
 {
     if ($groupType->isVariant()) {
         $variantGroupType = $this->groupTypeRepository->getVariantGroupType();
         if (null !== $variantGroupType && $variantGroupType->getId() !== $groupType->getId()) {
             $this->context->buildViolation($constraint->message)->addViolation();
         }
     }
 }
 function it_adds_a_violation_if_a_variant_group_type_already_exists($context, $repository, GroupTypeInterface $groupType, GroupTypeInterface $variantGroupType, UniqueVariantGroupType $constraint, ConstraintViolationBuilderInterface $violation)
 {
     $groupType->isVariant()->willReturn(true);
     $groupType->getId()->willReturn(2);
     $repository->getVariantGroupType()->willReturn($variantGroupType);
     $variantGroupType->getId()->willReturn(1);
     $context->buildViolation($constraint->message)->shouldBeCalled()->willReturn($violation);
     $violation->addViolation()->shouldBeCalled();
     $this->validate($groupType, $constraint);
 }
 /**
  * @param GroupTypeInterface $groupType
  *
  * @Given /^I should be on the ("([^"]*)" group type) page$/
  */
 public function iShouldBeOnTheGroupTypePage(GroupTypeInterface $groupType)
 {
     $expectedAddress = $this->getPage('GroupType edit')->getUrl(['id' => $groupType->getId()]);
     $this->assertAddress($expectedAddress);
 }