@@ -289,60 +289,22 @@ public function test_stamp_information()
289289 $ this ->assertArrayHasKey ('Symfony\Component\Messenger\Stamp\TransportMessageIdStamp ' , $ stamps );
290290 }
291291
292- public function test_resource_names ()
292+ public function test_throw_exception (): void
293293 {
294- $ transport = $ this ->getTransport ();
295- $ message = new SendEmailMessage ('Hello Again ' );
296-
297- // Test send operation
298- $ envelope = new Envelope ($ message , [
299- new \Symfony \Component \Messenger \Stamp \SentStamp ('test_transport ' , 'TestSender ' ),
300- ]);
301- $ transport ->send ($ envelope );
302-
303- $ this ->assertCount (1 , $ this ->storage );
304- $ sendSpan = $ this ->storage [0 ];
305- $ this ->assertTrue ($ sendSpan ->getAttributes ()->has ('resource.name ' ));
306- $ this ->assertEquals (
307- 'OpenTelemetry\Tests\Instrumentation\Symfony\tests\Integration\SendEmailMessage -> TestSender ' ,
308- $ sendSpan ->getAttributes ()->get ('resource.name ' )
309- );
310-
311- // Clear storage for next test
312- $ this ->storage = new ArrayObject ();
313-
314- // Test receive operation
315- $ envelope = new Envelope ($ message , [
316- new \Symfony \Component \Messenger \Stamp \ReceivedStamp ('test_transport ' ),
317- ]);
318-
319- // First send the message to the transport
320- $ transport ->send ($ envelope );
321-
322- // Create a worker and handle the message
323- $ bus = $ this ->getMessenger ();
324- $ worker = new \Symfony \Component \Messenger \Worker (
325- ['test_transport ' => $ transport ],
326- $ bus
327- );
328-
329- // Get and handle the message
330- $ messages = iterator_to_array ($ transport ->get ());
331- $ receivedEnvelope = $ messages [0 ];
332-
333- // Use reflection to call the protected handleMessage method
334- $ reflection = new \ReflectionClass ($ worker );
335- $ handleMessageMethod = $ reflection ->getMethod ('handleMessage ' );
336- $ handleMessageMethod ->setAccessible (true );
337- $ handleMessageMethod ->invoke ($ worker , $ receivedEnvelope , 'test_transport ' );
338-
339- $ this ->assertCount (1 , $ this ->storage );
340- $ receiveSpan = $ this ->storage [0 ];
341- $ this ->assertTrue ($ receiveSpan ->getAttributes ()->has ('resource.name ' ));
342- $ this ->assertEquals (
343- 'test_transport -> OpenTelemetry\Tests\Instrumentation\Symfony\tests\Integration\SendEmailMessage ' ,
344- $ receiveSpan ->getAttributes ()->get ('resource.name ' )
345- );
294+ $ this ->expectException (\RuntimeException::class);
295+ $ this ->expectExceptionMessage ('test ' );
296+
297+ $ bus = $ this ->getBus (__FUNCTION__ );
298+ $ bus ->dispatch (new TestMessage ());
299+ }
300+
301+ public function test_throw_exception_with_retry (): void
302+ {
303+ $ this ->expectException (\RuntimeException::class);
304+ $ this ->expectExceptionMessage ('test ' );
305+
306+ $ bus = $ this ->getBus (__FUNCTION__ );
307+ $ bus ->dispatch (new TestMessageWithRetry ());
346308 }
347309
348310 public function sendDataProvider (): array
0 commit comments