From e34c7e8db1a6bccee4ec0b71f3a178de64d46c85 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Wed, 19 Aug 2020 00:02:02 +0300 Subject: [PATCH] Added a redis driver test --- tests/PubSub/RedisDriverTest.php | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/PubSub/RedisDriverTest.php diff --git a/tests/PubSub/RedisDriverTest.php b/tests/PubSub/RedisDriverTest.php new file mode 100644 index 0000000..0558e25 --- /dev/null +++ b/tests/PubSub/RedisDriverTest.php @@ -0,0 +1,52 @@ +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, + ]); + } +}