/** * @expectedException \ApiPlatform\Core\Bridge\Symfony\Validator\Exception\ValidationException */ public function testThrowsValidationExceptionWithViolationsFound() { $data = new DummyEntity(); $expectedValidationGroups = ['a', 'b', 'c']; $violationsProphecy = $this->prophesize(ConstraintViolationListInterface::class); $violationsProphecy->count()->willReturn(1)->shouldBeCalled(); $violations = $violationsProphecy->reveal(); $validatorProphecy = $this->prophesize(ValidatorInterface::class); $validatorProphecy->validate($data, null, $expectedValidationGroups)->shouldBeCalled()->willReturn($violations)->shouldBeCalled(); $validator = $validatorProphecy->reveal(); list($resourceMetadataFactory, $event) = $this->createEventObject($expectedValidationGroups, $data); $validationViewListener = new ValidateListener($validator, $resourceMetadataFactory); $validationViewListener->onKernelView($event); }