|
3 | 3 | namespace Illuminate\Tests\Integration\Broadcasting;
|
4 | 4 |
|
5 | 5 | use Illuminate\Broadcasting\BroadcastEvent;
|
| 6 | +use Illuminate\Broadcasting\BroadcastManager; |
6 | 7 | use Illuminate\Broadcasting\UniqueBroadcastEvent;
|
| 8 | +use Illuminate\Config\Repository; |
| 9 | +use Illuminate\Container\Container; |
7 | 10 | use Illuminate\Contracts\Broadcasting\ShouldBeUnique;
|
8 | 11 | use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
9 | 12 | use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
10 | 13 | use Illuminate\Contracts\Cache\Repository as Cache;
|
11 | 14 | use Illuminate\Support\Facades\Broadcast;
|
12 | 15 | use Illuminate\Support\Facades\Bus;
|
13 | 16 | use Illuminate\Support\Facades\Queue;
|
| 17 | +use InvalidArgumentException; |
14 | 18 | use Orchestra\Testbench\TestCase;
|
15 | 19 |
|
16 | 20 | class BroadcastManagerTest extends TestCase
|
@@ -50,6 +54,36 @@ public function testUniqueEventsCanBeBroadcast()
|
50 | 54 | $lockKey = 'laravel_unique_job:'.UniqueBroadcastEvent::class.TestEventUnique::class;
|
51 | 55 | $this->assertFalse($this->app->get(Cache::class)->lock($lockKey, 10)->get());
|
52 | 56 | }
|
| 57 | + |
| 58 | + public function testThrowExceptionWhenUnknownStoreIsUsed() |
| 59 | + { |
| 60 | + $this->expectException(InvalidArgumentException::class); |
| 61 | + $this->expectExceptionMessage('Broadcast connection [alien_connection] is not defined.'); |
| 62 | + |
| 63 | + $userConfig = [ |
| 64 | + 'broadcasting' => [ |
| 65 | + 'connections' => [ |
| 66 | + 'my_connection' => [ |
| 67 | + 'driver' => 'pusher', |
| 68 | + ], |
| 69 | + ], |
| 70 | + ], |
| 71 | + ]; |
| 72 | + |
| 73 | + $app = $this->getApp($userConfig); |
| 74 | + |
| 75 | + $broadcastManager = new BroadcastManager($app); |
| 76 | + |
| 77 | + $broadcastManager->connection('alien_connection'); |
| 78 | + } |
| 79 | + |
| 80 | + protected function getApp(array $userConfig) |
| 81 | + { |
| 82 | + $app = new Container; |
| 83 | + $app->singleton('config', fn () => new Repository($userConfig)); |
| 84 | + |
| 85 | + return $app; |
| 86 | + } |
53 | 87 | }
|
54 | 88 |
|
55 | 89 | class TestEvent implements ShouldBroadcast
|
|
0 commit comments