ProophTest\ServiceBus\CommandBusTest::it_queues_new_commands_as_long_as_it_is_dispatching PHP Method

it_queues_new_commands_as_long_as_it_is_dispatching() public method

    public function it_queues_new_commands_as_long_as_it_is_dispatching()
    {
        $messageHandler = new MessageHandler();
        $this->commandBus->utilize((new CommandRouter())->route(CustomMessage::class)->to($messageHandler)->route('initial message')->to(function () use($messageHandler) {
            $delayedMessage = new CustomMessage("delayed message");
            $this->commandBus->dispatch($delayedMessage);
            $this->assertEquals(0, $messageHandler->getInvokeCounter());
        }));
        $this->commandBus->dispatch('initial message');
        $this->assertEquals(1, $messageHandler->getInvokeCounter());
    }