Added a redis driver test

This commit is contained in:
Alex Renoki 2020-08-19 00:02:02 +03:00
parent a36d3366f1
commit e34c7e8db1
1 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,52 @@
<?php
namespace BeyondCode\LaravelWebSockets\Tests\PubSub;
use BeyondCode\LaravelWebSockets\PubSub\Drivers\RedisClient;
use BeyondCode\LaravelWebSockets\Tests\TestCase;
use React\EventLoop\Factory as LoopFactory;
use BeyondCode\LaravelWebSockets\Tests\Mocks\RedisFactory;
class RedisDriverTest extends TestCase
{
/**
* {@inheritdoc}
*/
public function setUp(): void
{
parent::setUp();
$this->runOnlyOnRedisReplication();
}
/** @test */
public function redis_listener_responds_properly_on_payload()
{
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
$this->pusherServer->onOpen($connection);
$channelData = [
'user_id' => 1,
'user_info' => [
'name' => 'Marcel',
],
];
$payload = json_encode([
'appId' => '1234',
'event' => 'test',
'data' => $channelData,
'socket' => $connection->socketId,
]);
$this->getSubscribeClient()->onMessage('1234:test-channel', $payload);
$this->getSubscribeClient()
->assertEventDispatched('message')
->assertCalledWithArgs('subscribe', ['1234:test-channel'])
->assertCalledWithArgs('onMessage', [
'1234:test-channel', $payload,
]);
}
}