function it_handles_priorities(InputConstraint $highPriority, InputConstraint $middlePriority, InputConstraint $lowPriority, Input $input) { $this->addConstraint($lowPriority, self::LOW_PRIORITY); $this->addConstraint($highPriority, self::HIGH_PRIORITY); $this->addConstraint($middlePriority, self::MIDDLE_PRIORITY); $invalidInputException = new InvalidInputException($input->getWrappedObject(), self::MESSAGE); $highPriority->throwIfInvalid($input)->shouldBeCalled(); $middlePriority->throwIfInvalid($input)->willThrow($invalidInputException); $lowPriority->throwIfInvalid($input)->shouldNotBeCalled(); $this->shouldThrow($invalidInputException)->duringThrowIfInvalid($input); }