From fa9d4bc636b90aae9ee8fdf3e63d47a5761c3eea Mon Sep 17 00:00:00 2001 From: slavarazum Date: Mon, 20 Nov 2023 21:32:14 +0000 Subject: [PATCH] Fix styles --- src/Storage/PresenceChannelUsersRedisRepository.php | 2 +- tests/Events/SomePresenceEvent.php | 2 +- tests/Events/SomePrivateEvent.php | 2 +- tests/Pest.php | 7 ++++--- tests/PresenceChannelTest.php | 3 ++- tests/PresenceChannelUsersRedisRepositoryTest.php | 10 +++++----- tests/WhisperTest.php | 3 ++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Storage/PresenceChannelUsersRedisRepository.php b/src/Storage/PresenceChannelUsersRedisRepository.php index 0e35d9e..033d8dc 100644 --- a/src/Storage/PresenceChannelUsersRedisRepository.php +++ b/src/Storage/PresenceChannelUsersRedisRepository.php @@ -8,7 +8,6 @@ use Illuminate\Redis\Connections\PhpRedisConnection; use Illuminate\Redis\Connections\PredisConnection; use Illuminate\Support\Facades\Redis; -use Illuminate\Support\Str; use Qruto\LaravelWave\BroadcastingUserIdentifier; class PresenceChannelUsersRedisRepository implements PresenceChannelUsersRepository @@ -149,6 +148,7 @@ public function removeConnection(Authenticatable $user, string $connectionId): a private function extractChannelNameFromKey(string $key): string { $keyParts = explode(':', $key); + // It is assumed that the channel name is always the second part of the key. // Adjust this according to your key structure. return $keyParts[1]; diff --git a/tests/Events/SomePresenceEvent.php b/tests/Events/SomePresenceEvent.php index 4a8d7a3..e329f8c 100644 --- a/tests/Events/SomePresenceEvent.php +++ b/tests/Events/SomePresenceEvent.php @@ -10,9 +10,9 @@ class SomePresenceEvent implements ShouldBroadcast { + use Dispatchable; use InteractsWithSockets; use SerializesModels; - use Dispatchable; public $someData = [ 'name' => 'presence', diff --git a/tests/Events/SomePrivateEvent.php b/tests/Events/SomePrivateEvent.php index 04d6110..de064fb 100644 --- a/tests/Events/SomePrivateEvent.php +++ b/tests/Events/SomePrivateEvent.php @@ -10,9 +10,9 @@ class SomePrivateEvent implements ShouldBroadcast { + use Dispatchable; use InteractsWithSockets; use SerializesModels; - use Dispatchable; public $name = 'private'; diff --git a/tests/Pest.php b/tests/Pest.php index 34402eb..beba50d 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -5,13 +5,14 @@ use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Str; use Illuminate\Support\Traits\ReflectsClosures; -use function PHPUnit\Framework\assertCount; -use function PHPUnit\Framework\assertSame; -use function PHPUnit\Framework\assertTrue; use Qruto\LaravelWave\Tests\RedisConnectionMock; use Qruto\LaravelWave\Tests\Support\User; use Qruto\LaravelWave\Tests\TestCase; +use function PHPUnit\Framework\assertCount; +use function PHPUnit\Framework\assertSame; +use function PHPUnit\Framework\assertTrue; + uses(TestCase::class)->in(__DIR__); uses()->beforeEach(function () { diff --git a/tests/PresenceChannelTest.php b/tests/PresenceChannelTest.php index 782c5af..b4d8e28 100644 --- a/tests/PresenceChannelTest.php +++ b/tests/PresenceChannelTest.php @@ -4,13 +4,14 @@ use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Redis; -use function Pest\Laravel\actingAs; use Qruto\LaravelWave\Events\PresenceChannelJoinEvent; use Qruto\LaravelWave\Events\SseConnectionClosedEvent; use Qruto\LaravelWave\Tests\Events\SomePresenceEvent; use Qruto\LaravelWave\Tests\Events\SomePrivateEvent; use Qruto\LaravelWave\Tests\Support\User; +use function Pest\Laravel\actingAs; + it('send join event on join request', function () { Event::fake([PresenceChannelJoinEvent::class]); diff --git a/tests/PresenceChannelUsersRedisRepositoryTest.php b/tests/PresenceChannelUsersRedisRepositoryTest.php index a8afd25..acfe207 100644 --- a/tests/PresenceChannelUsersRedisRepositoryTest.php +++ b/tests/PresenceChannelUsersRedisRepositoryTest.php @@ -47,7 +47,7 @@ function userChannelsKey(Authenticatable $user): string ))->toBe(true); }); -it('successfully saves second user connection', function () use ($connectionId, $channel) { +it('successfully saves second user connection', function () { Redis::shouldReceive('hexists')->once()->withArgs([ 'laravel_database_channels:community:users', $this->user->getAuthIdentifierForBroadcasting(), @@ -184,10 +184,10 @@ function userChannelsKey(Authenticatable $user): string $removedConnections = $this->repository->removeConnection($this->user, $connectionId); expect($removedConnections)->toEqual([ -// [ -// 'channel' => 'channel1', -// 'user_info' => ['email' => 'test1@example.com'], -// ], + // [ + // 'channel' => 'channel1', + // 'user_info' => ['email' => 'test1@example.com'], + // ], [ 'channel' => 'channel2', 'user_info' => ['email' => 'test2@example.com'], diff --git a/tests/WhisperTest.php b/tests/WhisperTest.php index 922066a..06b4d72 100644 --- a/tests/WhisperTest.php +++ b/tests/WhisperTest.php @@ -1,10 +1,11 @@