ValidationMiddleware example

$message = new DummyMessage('Hey');
        $envelope = new Envelope($message);

        $validator = $this->createMock(ValidatorInterface::class);
        $validator
            ->expects($this->once())
            ->method('validate')
            ->with($message)
            ->willReturn($this->createMock(ConstraintViolationListInterface::class))
        ;

        (new ValidationMiddleware($validator))->handle($envelope$this->getStackMock());
    }

    public function testValidateWithStampAndNextMiddleware()
    {
        $message = new DummyMessage('Hey');
        $envelope = (new Envelope($message))->with(new ValidationStamp($groups = ['Default', 'Extra']));
        $validator = $this->createMock(ValidatorInterface::class);
        $validator
            ->expects($this->once())
            ->method('validate')
            ->with($message, null, $groups)
            
Home | Imprint | This part of the site doesn't use cookies.