expectHandledMessage example

$messageBus = new MessageBus([
            $middleware,
            new DispatchingMiddleware($eventBus[
                new Envelope($event[new DispatchAfterCurrentBusStamp()]),
            ]),
            $commandHandlingMiddleware,
        ]);

        $commandHandlingMiddleware->expects($this->once())
            ->method('handle')
            ->with($this->expectHandledMessage($message))
            ->willReturnCallback(fn ($envelope, StackInterface $stack) => $stack->next()->handle($envelope$stack));
        $eventHandlingMiddleware->expects($this->once())
            ->method('handle')
            ->with($this->expectHandledMessage($event))
            ->willReturnCallback(fn ($envelope, StackInterface $stack) => $stack->next()->handle($envelope$stack));
        $messageBus->dispatch($message);
    }

    public function testDispatchOutOfAnotherHandlerDispatchesAndRemoveStamp()
    {
        $event = new DummyEvent('First event');

        
Home | Imprint | This part of the site doesn't use cookies.