Updated tests

This commit is contained in:
Alex Renoki 2020-09-04 22:26:46 +03:00
parent 1dfe14a517
commit 1e2672d9e0
3 changed files with 9 additions and 7 deletions

View File

@ -55,7 +55,7 @@ class PresenceChannelReplicationTest extends TestCase
->assertCalled('publish'); ->assertCalled('publish');
$this->assertNotNull( $this->assertNotNull(
Redis::hget('laravel_database_1234:presence-channel', $connection->socketId) $this->redis->hget('laravel_database_1234:presence-channel', $connection->socketId)
); );
} }

View File

@ -47,7 +47,7 @@ class ConnectionTest extends TestCase
{ {
$this->runOnlyOnRedisReplication(); $this->runOnlyOnRedisReplication();
Redis::hdel('laravel_database_1234', 'connections'); $this->redis->hdel('laravel_database_1234', 'connections');
$this->app['config']->set('websockets.apps.0.capacity', 2); $this->app['config']->set('websockets.apps.0.capacity', 2);

View File

@ -79,8 +79,6 @@ abstract class TestCase extends BaseTestCase
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->pusherServer = $this->app->make(config('websockets.handlers.websocket')); $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() protected function configurePubSub()
{ {
$replicationDriver = config('websockets.replication.driver', 'local');
// Replace the publish and subscribe clients with a Mocked // Replace the publish and subscribe clients with a Mocked
// factory lazy instance on boot. // factory lazy instance on boot.
$this->app->singleton(ReplicationInterface::class, function () { $this->app->singleton(ReplicationInterface::class, function () use ($replicationDriver) {
$driver = config('websockets.replication.driver', 'local');
$client = config( $client = config(
"websockets.replication.{$driver}.client", "websockets.replication.{$driver}.client",
\BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient::class \BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient::class
@ -286,6 +284,10 @@ abstract class TestCase extends BaseTestCase
$this->loop, Mocks\RedisFactory::class $this->loop, Mocks\RedisFactory::class
); );
}); });
if ($replicationDriver === 'redis') {
$this->redis = Redis::connection();
}
} }
/** /**