diff --git a/tests/Channels/PresenceChannelReplicationTest.php b/tests/Channels/PresenceChannelReplicationTest.php index d416aef..ede78bb 100644 --- a/tests/Channels/PresenceChannelReplicationTest.php +++ b/tests/Channels/PresenceChannelReplicationTest.php @@ -55,7 +55,7 @@ class PresenceChannelReplicationTest extends TestCase ->assertCalled('publish'); $this->assertNotNull( - Redis::hget('laravel_database_1234:presence-channel', $connection->socketId) + $this->redis->hget('laravel_database_1234:presence-channel', $connection->socketId) ); } diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 68d7fbe..fc19c34 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -47,7 +47,7 @@ class ConnectionTest extends TestCase { $this->runOnlyOnRedisReplication(); - Redis::hdel('laravel_database_1234', 'connections'); + $this->redis->hdel('laravel_database_1234', 'connections'); $this->app['config']->set('websockets.apps.0.capacity', 2); diff --git a/tests/TestCase.php b/tests/TestCase.php index 0cf6603..48b9d21 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -79,8 +79,6 @@ abstract class TestCase extends BaseTestCase $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); $this->pusherServer = $this->app->make(config('websockets.handlers.websocket')); - - $this->redis = Redis::connection(); } /** @@ -272,11 +270,11 @@ abstract class TestCase extends BaseTestCase */ protected function configurePubSub() { + $replicationDriver = config('websockets.replication.driver', 'local'); + // Replace the publish and subscribe clients with a Mocked // factory lazy instance on boot. - $this->app->singleton(ReplicationInterface::class, function () { - $driver = config('websockets.replication.driver', 'local'); - + $this->app->singleton(ReplicationInterface::class, function () use ($replicationDriver) { $client = config( "websockets.replication.{$driver}.client", \BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient::class @@ -286,6 +284,10 @@ abstract class TestCase extends BaseTestCase $this->loop, Mocks\RedisFactory::class ); }); + + if ($replicationDriver === 'redis') { + $this->redis = Redis::connection(); + } } /**