/**
  * {@inheritdoc}
  */
 public function validate($instruction, Constraint $constraint)
 {
     if (null === $instruction->getCodeLength() || null === $instruction->getAmount()) {
         return;
     }
     if (!$this->generationPolicy->isGenerationPossible($instruction)) {
         $this->context->addViolation($constraint->message, array('%expectedAmount%' => $instruction->getAmount(), '%codeLength%' => $instruction->getCodeLength(), '%possibleAmount%' => $this->generationPolicy->getPossibleGenerationAmount($instruction)));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function validate($instruction, Constraint $constraint)
 {
     if (null === $instruction->getCodeLength() || null === $instruction->getAmount()) {
         return;
     }
     /** @var PromotionCouponGeneratorInstructionInterface $value */
     Assert::isInstanceOf($instruction, PromotionCouponGeneratorInstructionInterface::class);
     /** @var CouponPossibleGenerationAmount $constraint */
     Assert::isInstanceOf($constraint, CouponPossibleGenerationAmount::class);
     if (!$this->generationPolicy->isGenerationPossible($instruction)) {
         $this->context->addViolation($constraint->message, array('%expectedAmount%' => $instruction->getAmount(), '%codeLength%' => $instruction->getCodeLength(), '%possibleAmount%' => $this->generationPolicy->getPossibleGenerationAmount($instruction)));
     }
 }
 function it_not_adds_violation(ExecutionContextInterface $context, CouponPossibleGenerationAmount $constraint, InstructionInterface $instruction, GenerationPolicyInterface $generationPolicy)
 {
     $instruction->getAmount()->willReturn(5);
     $instruction->getCodeLength()->willReturn(1);
     $generationPolicy->isGenerationPossible($instruction)->willReturn(true);
     $generationPolicy->getPossibleGenerationAmount($instruction)->shouldNotBeCalled();
     $context->addViolation($constraint->message)->shouldNotBeCalled();
     $this->validate($instruction, $constraint);
 }
 function it_does_not_add_violation(ExecutionContextInterface $context, PromotionCouponGeneratorInstructionInterface $instruction, GenerationPolicyInterface $generationPolicy)
 {
     $constraint = new CouponPossibleGenerationAmount();
     $instruction->getAmount()->willReturn(5);
     $instruction->getCodeLength()->willReturn(1);
     $generationPolicy->isGenerationPossible($instruction)->willReturn(true);
     $generationPolicy->getPossibleGenerationAmount($instruction)->shouldNotBeCalled();
     $context->addViolation($constraint->message, Argument::any())->shouldNotBeCalled();
     $this->validate($instruction, $constraint);
 }