@@ -79,7 +79,7 @@ public function testBreadcrumbWithConsoleListener()
7979 $ this ->application ->doRun (new ArgvInput (['bin/console ' , 'sentry:breadcrumb:test ' ]), new NullOutput ());
8080 $ this ->fail ();
8181 } catch (\Throwable $ e ) {
82- $ this ->assertSame ( $ e ->getMessage (), ' Breadcrumb error ' );
82+ $ this ->assertEquals ( ' Breadcrumb error ' , $ e ->getMessage ());
8383 }
8484
8585 $ event = Event::createEvent ();
@@ -119,8 +119,8 @@ public function testSubCommandBreadcrumbs()
119119 });
120120
121121 $ this ->assertNotNull ($ modifiedEvent );
122- // We do not have breadcrumbs here because no error happened and the scope was popped .
123- $ this ->assertCount (0 , $ modifiedEvent ->getBreadcrumbs ());
122+ // We have breadcrumbs but only from the root console command .
123+ $ this ->assertCount (2 , $ modifiedEvent ->getBreadcrumbs ());
124124 }
125125
126126 /**
@@ -140,7 +140,7 @@ public function testCrashingSubcommand()
140140 $ this ->application ->doRun (new ArgvInput (['bin/console ' , 'sentry:subcommand:test ' ]), new NullOutput ());
141141 $ this ->fail ();
142142 } catch (\Throwable $ e ) {
143- $ this ->assertSame ( $ e ->getMessage (), ' Breadcrumb error ' );
143+ $ this ->assertEquals ( ' Breadcrumb error ' , $ e ->getMessage ());
144144 }
145145
146146 $ event = Event::createEvent ();
@@ -152,7 +152,7 @@ public function testCrashingSubcommand()
152152
153153 $ this ->assertNotNull ($ modifiedEvent );
154154 $ this ->assertCount (2 , $ modifiedEvent ->getBreadcrumbs ());
155- $ this ->assertSame ( $ modifiedEvent ->getTags ()['console.command ' ], ' sentry:breadcrumb:test ' );
155+ $ this ->assertEquals ( ' sentry:breadcrumb:test ' , $ modifiedEvent ->getTags ()['console.command ' ]);
156156 }
157157
158158 /**
@@ -176,7 +176,7 @@ public function testRunSecondCommandAfterCrashingCommand()
176176 $ this ->application ->doRun (new ArgvInput (['bin/console ' , 'sentry:subcommand:test ' ]), new NullOutput ());
177177 $ this ->fail ();
178178 } catch (\Throwable $ e ) {
179- $ this ->assertSame ( $ e ->getMessage (), ' Breadcrumb error ' );
179+ $ this ->assertEquals ( ' Breadcrumb error ' , $ e ->getMessage ());
180180 }
181181
182182 $ command = new SentryDummyTestCommand ($ this ->logger );
@@ -195,6 +195,31 @@ public function testRunSecondCommandAfterCrashingCommand()
195195 // Breadcrumbs contain all log entries until the sentry:dummy:test command crash.
196196 $ this ->assertCount (3 , $ modifiedEvent ->getBreadcrumbs ());
197197 // console.command tag is properly set to the last command
198- $ this ->assertSame ($ modifiedEvent ->getTags ()['console.command ' ], 'sentry:dummy:test ' );
198+ $ this ->assertEquals ('sentry:dummy:test ' , $ modifiedEvent ->getTags ()['console.command ' ]);
199+ }
200+
201+ /**
202+ * Tests that even if no errors occur, breadcrumb information is available.
203+ *
204+ * @return void
205+ * @throws \Throwable
206+ */
207+ public function testBreadcrumbsAreAvailableAfterCommandTermination ()
208+ {
209+ $ command = new SentryDummyTestCommand ($ this ->logger );
210+ $ this ->application ->add ($ command );
211+
212+ $ this ->application ->doRun (new ArgvInput (['bin/console ' , 'sentry:dummy:test ' ]), new NullOutput ());
213+
214+ $ event = Event::createEvent ();
215+ $ modifiedEvent = null ;
216+ $ this ->hub ->configureScope (function (Scope $ scope ) use ($ event , &$ modifiedEvent ) {
217+ $ modifiedEvent = $ scope ->applyToEvent ($ event );
218+ });
219+
220+ $ this ->assertNotNull ($ modifiedEvent );
221+ $ this ->assertCount (1 , $ modifiedEvent ->getBreadcrumbs ());
222+ $ this ->assertEquals ('This is a dummy message ' , $ modifiedEvent ->getBreadcrumbs ()[0 ]->getMessage ());
223+ $ this ->assertEquals ('sentry:dummy:test ' , $ modifiedEvent ->getTags ()['console.command ' ]);
199224 }
200225}
0 commit comments