function it_does_not_validate_method_with_no_constraints(MethodInterface $method, ValidatorInterface $validator) { $constraints = []; $method->getValidationConstraints()->shouldBeCalled()->willReturn($constraints); $validator->validate([], $constraints)->shouldNotBeCalled(); $this->validate($method); }
public function validate(MethodInterface $method) { $constraints = $method->getValidationConstraints(); if (empty($constraints)) { return; } $violations = $this->validator->validate($method->getAttributes(), $constraints); if (count($violations) !== 0) { throw new Exception\InvalidAttributeValue('Your method contains invalid attribute value', $violations); } }