From 92870c088a2a9525b58b65810d12cc2a114e0c83 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Sat, 22 Aug 2020 21:54:48 +0300 Subject: [PATCH] wip --- src/Statistics/DnsResolver.php | 59 --------------------- tests/Commands/StartWebSocketServerTest.php | 2 +- tests/PubSub/RedisDriverTest.php | 34 ++++++++++++ 3 files changed, 35 insertions(+), 60 deletions(-) delete mode 100644 src/Statistics/DnsResolver.php diff --git a/src/Statistics/DnsResolver.php b/src/Statistics/DnsResolver.php deleted file mode 100644 index 57cfdcb..0000000 --- a/src/Statistics/DnsResolver.php +++ /dev/null @@ -1,59 +0,0 @@ -resolveInternal($domain); - } - - /** - * Resolve all domains. - * - * @param string $domain - * @param string $type - * @return FulfilledPromise - */ - public function resolveAll($domain, $type) - { - return $this->resolveInternal($domain, $type); - } - - /** - * Resolve the internal domain. - * - * @param string $domain - * @param string $type - * @return FulfilledPromise - */ - private function resolveInternal($domain, $type = null) - { - return new FulfilledPromise($this->internalIp); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->internalIp; - } -} diff --git a/tests/Commands/StartWebSocketServerTest.php b/tests/Commands/StartWebSocketServerTest.php index 637c1c8..00d0d32 100644 --- a/tests/Commands/StartWebSocketServerTest.php +++ b/tests/Commands/StartWebSocketServerTest.php @@ -9,7 +9,7 @@ class StartWebSocketServerTest extends TestCase /** @test */ public function does_not_fail_if_building_up() { - $this->artisan('websockets:serve', ['--test' => true]); + $this->artisan('websockets:serve', ['--test' => true, '--debug' => true]); $this->assertTrue(true); } diff --git a/tests/PubSub/RedisDriverTest.php b/tests/PubSub/RedisDriverTest.php index e6585a1..e6caf01 100644 --- a/tests/PubSub/RedisDriverTest.php +++ b/tests/PubSub/RedisDriverTest.php @@ -2,7 +2,10 @@ namespace BeyondCode\LaravelWebSockets\Tests\PubSub; +use BeyondCode\LaravelWebSockets\PubSub\Drivers\RedisClient; use BeyondCode\LaravelWebSockets\Tests\TestCase; +use BeyondCode\LaravelWebSockets\Tests\Mocks\RedisFactory; +use React\EventLoop\Factory as LoopFactory; class RedisDriverTest extends TestCase { @@ -46,4 +49,35 @@ class RedisDriverTest extends TestCase '1234:test-channel', $payload, ]); } + + /** @test */ + public function redis_listener_responds_properly_on_payload_by_direct_call() + { + $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, + ]); + + $client = (new RedisClient)->boot( + LoopFactory::create(), RedisFactory::class + ); + + $client->onMessage('1234:test-channel', $payload); + + $client->getSubscribeClient() + ->assertEventDispatched('message'); + } }