From e259cac51eec9308774ed503688baba9d0e846ec Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 3 Sep 2019 11:50:10 -0400 Subject: [PATCH] Remove duplicate client mock client, simplify test trait --- tests/Mocks/FakeReplicationClient.php | 126 -------------------------- tests/TestsReplication.php | 5 +- 2 files changed, 2 insertions(+), 129 deletions(-) delete mode 100644 tests/Mocks/FakeReplicationClient.php diff --git a/tests/Mocks/FakeReplicationClient.php b/tests/Mocks/FakeReplicationClient.php deleted file mode 100644 index 5ad21b3..0000000 --- a/tests/Mocks/FakeReplicationClient.php +++ /dev/null @@ -1,126 +0,0 @@ -channels["$appId:$channel"][$socketId] = $data; - } - - /** - * Remove a member from the channel. To be called when they have - * unsubscribed from the channel. - * - * @param string $appId - * @param string $channel - * @param string $socketId - */ - public function leaveChannel(string $appId, string $channel, string $socketId) - { - unset($this->channels["$appId:$channel"][$socketId]); - if (empty($this->channels["$appId:$channel"])) { - unset($this->channels["$appId:$channel"]); - } - } - - /** - * Retrieve the full information about the members in a presence channel. - * - * @param string $appId - * @param string $channel - * @return PromiseInterface - */ - public function channelMembers(string $appId, string $channel) : PromiseInterface - { - $data = array_map(function ($user) { - return json_decode($user); - }, $this->channels["$appId:$channel"]); - - return new FulfilledPromise($data); - } - - /** - * Get the amount of users subscribed for each presence channel. - * - * @param string $appId - * @param array $channelNames - * @return PromiseInterface - */ - public function channelMemberCounts(string $appId, array $channelNames) : PromiseInterface - { - $data = []; - - foreach ($channelNames as $channel) { - $data[$channel] = count($this->channels["$appId:$channel"]); - } - - return new FulfilledPromise($data); - } -} diff --git a/tests/TestsReplication.php b/tests/TestsReplication.php index 437f8b3..e179ea0 100644 --- a/tests/TestsReplication.php +++ b/tests/TestsReplication.php @@ -2,17 +2,16 @@ namespace BeyondCode\LaravelWebSockets\Tests; -use React\EventLoop\Factory; use Illuminate\Support\Facades\Config; +use BeyondCode\LaravelWebSockets\PubSub\Drivers\LocalClient; use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; -use BeyondCode\LaravelWebSockets\Tests\Mocks\FakeReplicationClient; trait TestsReplication { public function setupReplication() { app()->singleton(ReplicationInterface::class, function () { - return (new FakeReplicationClient())->boot(Factory::create()); + return new LocalClient(); }); Config::set([