1111use Symfony \Component \Messenger \MessageBus ;
1212use Symfony \Component \Messenger \MessageBusInterface ;
1313use Symfony \Component \Messenger \Transport \InMemory \InMemoryTransport ;
14- use Symfony \Component \Messenger \Transport \InMemoryTransport as LegacyInmemoryTransport ;
14+ use Symfony \Component \Messenger \Transport \InMemoryTransport as LegacyInMemoryTransport ;
15+ use Symfony \Component \Messenger \Transport \TransportInterface ;
1516
1617final class SendEmailMessage
1718{
@@ -42,7 +43,7 @@ protected function getTransport()
4243 }
4344
4445 // Symfony 5+
45- return new LegacyInmemoryTransport ();
46+ return new LegacyInMemoryTransport ();
4647 }
4748
4849 /**
@@ -98,7 +99,7 @@ public function test_send_message($message, string $spanName, int $kind, array $
9899 }
99100 }
100101
101- public function test_can_sustain_throw ()
102+ public function test_can_sustain_throw_while_dispatching ()
102103 {
103104 $ bus = new class () implements MessageBusInterface {
104105 public function dispatch (object $ message , array $ stamps = []): Envelope
@@ -117,6 +118,39 @@ public function dispatch(object $message, array $stamps = []): Envelope
117118 }
118119 }
119120
121+ public function test_can_sustain_throw_while_sending ()
122+ {
123+ $ transport = new class () implements TransportInterface {
124+ public function get (): iterable
125+ {
126+ throw new \Exception ('booo! ' );
127+ }
128+
129+ public function ack (Envelope $ envelope ): void
130+ {
131+ throw new \Exception ('booo! ' );
132+ }
133+
134+ public function reject (Envelope $ envelope ): void
135+ {
136+ throw new \Exception ('booo! ' );
137+ }
138+
139+ public function send (Envelope $ envelope ): Envelope
140+ {
141+ throw new \Exception ('booo! ' );
142+ }
143+ };
144+
145+ try {
146+ $ transport ->send (new Envelope (new SendEmailMessage ('Hello Again ' )));
147+ } catch (\Throwable $ e ) {
148+ $ this ->assertCount (1 , $ this ->storage );
149+
150+ $ span = $ this ->storage [0 ];
151+ }
152+ }
153+
120154 public function sendDataProvider (): array
121155 {
122156 return [
0 commit comments