8000 Failing test case: `TraceableMessageBus` crashes when computing backt… · symfony/symfony@a894125 · GitHub
[go: up one dir, main page]

Skip to content

Commit a894125

Browse files
committed
Failing test case: TraceableMessageBus crashes when computing backtrace of array_map() call
This test shows that `array_map([new TraceableMessageBus(...), 'dispatch'], $messages)` does not work at all, because `debug_backtrace()` is used in internals to compute the call-site, and it is not considering the fact that the caller may be: * an internal PHP function * a callback (this example test scenario) * generated code (`eval()` result) The output of such a failure: ``` 1) Symfony\Component\Messenger\Tests\TraceableMessageBusTest::testItTracesExceptionsWhenMessageBusIsFiredFromArrayCallback Undefined array key "line" /app/src/Symfony/Component/Messenger/TraceableMessageBus.php:66 /app/src/Symfony/Component/Messenger/TraceableMessageBus.php:36 /app/src/Symfony/Component/Messenger/Tests/TraceableMessageBusTest.php:175 ```
1 parent 085a42f commit a894125

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/Messenger/Tests/TraceableMessageBusTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,22 @@ public function testItTracesExceptions()
156156
],
157157
], $actualTracedMessage);
158158
}
159+
160+
public function testItTracesExceptionsWhenMessageBusIsFiredFromArrayCallback(): void
161+
{
162+
$message = new DummyMessage('Hello');
163+
$exception = new \RuntimeException();
164+
165+
$bus = $this->createMock(MessageBusInterface::class);
166+
$bus->expects($this->once())
167+
->method('dispatch')
168+
->with($message)
169+
->willThrowException($exception);
170+
171+
$traceableBus = new TraceableMessageBus($bus);
172+
173+
$this->expectExceptionObject($exception);
174+
175+
array_map([$traceableBus, 'dispatch'], [$message]);
176+
}
159177
}

0 commit comments

Comments
 (0)
0