TestTracesWithHandleTraitAction example

 $actualTracedMessage);
    }

    public function testItTracesDispatchWhenHandleTraitIsUsed()
    {
        $message = new DummyMessage('Hello');

        $bus = $this->createMock(MessageBusInterface::class);
        $bus->expects($this->once())->method('dispatch')->with($message)->willReturn((new Envelope($message))->with($stamp = new HandledStamp('result', 'handlerName')));

        $traceableBus = new TraceableMessageBus($bus);
        (new TestTracesWithHandleTraitAction($traceableBus))($message);
        $this->assertCount(1, $tracedMessages = $traceableBus->getDispatchedMessages());
        $actualTracedMessage = $tracedMessages[0];
        unset($actualTracedMessage['callTime']); // don't check, too variable         $this->assertEquals([
            'message' => $message,
            'stamps' => [],
            'stamps_after_dispatch' => [$stamp],
            'caller' => [
                'name' => 'TestTracesWithHandleTraitAction.php',
                'file' => (new \ReflectionClass(TestTracesWithHandleTraitAction::class))->getFileName(),
                'line' => (new \ReflectionMethod(TestTracesWithHandleTraitAction::class, '__invoke'))->getStartLine() + 2,
            ],
Home | Imprint | This part of the site doesn't use cookies.