Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 1e2672d

Browse files
committed
Updated tests
1 parent 1dfe14a commit 1e2672d

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

tests/Channels/PresenceChannelReplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function clients_with_valid_auth_signatures_can_join_presence_channels()
5555
->assertCalled('publish');
5656

5757
$this->assertNotNull(
58-
Redis::hget('laravel_database_1234:presence-channel', $connection->socketId)
58+
$this->redis->hget('laravel_database_1234:presence-channel', $connection->socketId)
5959
);
6060
}
6161

tests/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function app_can_not_exceed_maximum_capacity_on_redis_replication()
4747
{
4848
$this->runOnlyOnRedisReplication();
4949

50-
Redis::hdel('laravel_database_1234', 'connections');
50+
$this->redis->hdel('laravel_database_1234', 'connections');
5151

5252
$this->app['config']->set('websockets.apps.0.capacity', 2);
5353

tests/TestCase.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public function setUp(): void
7979
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
8080

8181
$this->pusherServer = $this->app->make(config('websockets.handlers.websocket'));
82-
83-
$this->redis = Redis::connection();
8482
}
8583

8684
/**
@@ -272,11 +270,11 @@ protected function getChannel(ConnectionInterface $connection, string $channelNa
272270
*/
273271
protected function configurePubSub()
274272
{
273+
$replicationDriver = config('websockets.replication.driver', 'local');
274+
275275
// Replace the publish and subscribe clients with a Mocked
276276
// factory lazy instance on boot.
277-
$this->app->singleton(ReplicationInterface::class, function () {
278-
$driver = config('websockets.replication.driver', 'local');
279-
277+
$this->app->singleton(ReplicationInterface::class, function () use ($replicationDriver) {
280278
$client = config(
281279
"websockets.replication.{$driver}.client",
282280
\BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient::class
@@ -286,6 +284,10 @@ protected function configurePubSub()
286284
$this->loop, Mocks\RedisFactory::class
287285
);
288286
});
287+
288+
if ($replicationDriver === 'redis') {
289+
$this->redis = Redis::connection();
290+
}
289291
}
290292

291293
/**

0 commit comments

Comments
 (0)