File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
tests/Integration/Database Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,9 @@ public function reconnect($name = null)
330330 return $ this ->connection ($ name );
331331 }
332332
333- return $ this ->refreshPdoConnections ($ name );
333+ return tap ($ this ->refreshPdoConnections ($ name ), function ($ connection ) {
334+ $ this ->dispatchConnectionEstablishedEvent ($ connection );
335+ });
334336 }
335337
336338 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Illuminate \Tests \Integration \Database ;
4+
5+ use Illuminate \Database \Events \ConnectionEstablished ;
6+ use Illuminate \Foundation \Testing \DatabaseMigrations ;
7+ use Illuminate \Support \Facades \Event ;
8+ use Orchestra \Testbench \Attributes \WithMigration ;
9+ use Orchestra \Testbench \TestCase ;
10+
11+ use function Orchestra \Testbench \artisan ;
12+
13+ class EventConnectionEstablishedTest extends TestCase
14+ {
15+ use DatabaseMigrations;
16+
17+ #[WithMigration]
18+ public function testItListenToEstablishedConnectionOnReconnect ()
19+ {
20+ Event::fake ([ConnectionEstablished::class]);
21+
22+ Event::assertNotDispatched (ConnectionEstablished::class);
23+
24+ artisan ($ this , 'migrate:fresh ' );
25+
26+ Event::assertDispatched (ConnectionEstablished::class);
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments