ApiPlatform\Core\Tests\Bridge\Symfony\Validator\EventListener\ValidateListenerTest::testThrowsValidationExceptionWithViolationsFound PHP Method

testThrowsValidationExceptionWithViolationsFound() public method

    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);
    }