Skip to content

Commit

Permalink
Check if channel variable isn't null when passed as a filter on chann…
Browse files Browse the repository at this point in the history
…els() method in ArrayChannelManager
  • Loading branch information
kirills-morozovs committed Dec 27, 2024
1 parent 9469732 commit 424ea55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Protocols/Pusher/Managers/ArrayChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function channels(?string $channel = null): Channel|array|null
{
$channels = $this->applications[$this->application->id()] ?? [];

if ($channel) {
if (isset($channel)) {
return $channels[$channel] ?? null;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Protocols/Pusher/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
]);
});

it('can subscribe to an empty channel', function () {
$this->pusher->handle(
$this->connection,
'pusher:subscribe',
['channel' => '']
);

$this->connection->assertReceived([
'event' => 'pusher_internal:subscription_succeeded',
'data' => '{}',
]);
});

it('can unsubscribe from a channel', function () {
$this->pusher->handle(
$this->connection,
Expand Down

0 comments on commit 424ea55

Please sign in to comment.