|
3 | 3 | namespace Illuminate\Tests\Integration\Broadcasting;
|
4 | 4 |
|
5 | 5 | use Illuminate\Broadcasting\BroadcastEvent;
|
| 6 | +use Illuminate\Broadcasting\BroadcastException; |
6 | 7 | use Illuminate\Broadcasting\BroadcastManager;
|
7 | 8 | use Illuminate\Broadcasting\UniqueBroadcastEvent;
|
8 | 9 | use Illuminate\Config\Repository;
|
|
17 | 18 | use Illuminate\Support\Facades\Queue;
|
18 | 19 | use InvalidArgumentException;
|
19 | 20 | use Orchestra\Testbench\TestCase;
|
| 21 | +use RuntimeException; |
20 | 22 |
|
21 | 23 | class BroadcastManagerTest extends TestCase
|
22 | 24 | {
|
@@ -100,6 +102,35 @@ public function testThrowExceptionWhenUnknownStoreIsUsed()
|
100 | 102 | $broadcastManager->connection('alien_connection');
|
101 | 103 | }
|
102 | 104 |
|
| 105 | + public function testThrowExceptionWhenDriverCreationFails() |
| 106 | + { |
| 107 | + $userConfig = [ |
| 108 | + 'broadcasting' => [ |
| 109 | + 'connections' => [ |
| 110 | + 'log_connection_1' => [ |
| 111 | + 'driver' => 'log', |
| 112 | + ], |
| 113 | + ], |
| 114 | + ], |
| 115 | + ]; |
| 116 | + |
| 117 | + $app = $this->getApp($userConfig); |
| 118 | + $app->singleton(\Psr\Log\LoggerInterface::class, function () { |
| 119 | + throw new \RuntimeException('Logger service not available'); |
| 120 | + }); |
| 121 | + |
| 122 | + $broadcastManager = new BroadcastManager($app); |
| 123 | + |
| 124 | + try { |
| 125 | + $broadcastManager->connection('log_connection_1'); |
| 126 | + $this->fail('Expected BroadcastException was not thrown'); |
| 127 | + } catch (RuntimeException $e) { |
| 128 | + $this->assertStringContainsString('Failed to create broadcaster for connection "log_connection_1"', $e->getMessage()); |
| 129 | + $this->assertStringContainsString('Logger service not available', $e->getMessage()); |
| 130 | + $this->assertInstanceOf(\RuntimeException::class, $e->getPrevious()); |
| 131 | + } |
| 132 | + } |
| 133 | + |
103 | 134 | protected function getApp(array $userConfig)
|
104 | 135 | {
|
105 | 136 | $app = new Container;
|
|
0 commit comments