Skip to content

Commit a058259

Browse files
Check if channel variable isn't null when passed as a filter on channels() method in ArrayChannelManager (#292)
Co-authored-by: Joe Dixon <hello@joedixon.co.uk>
1 parent 16a5bda commit a058259

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Protocols/Pusher/Managers/ArrayChannelManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function channels(?string $channel = null): Channel|array|null
134134
{
135135
$channels = $this->applications[$this->application->id()] ?? [];
136136

137-
if ($channel) {
137+
if (isset($channel)) {
138138
return $channels[$channel] ?? null;
139139
}
140140

tests/Unit/Protocols/Pusher/EventTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
]);
3939
});
4040

41+
it('can subscribe to an empty channel', function () {
42+
$this->pusher->handle(
43+
$this->connection,
44+
'pusher:subscribe',
45+
['channel' => '']
46+
);
47+
48+
$this->connection->assertReceived([
49+
'event' => 'pusher_internal:subscription_succeeded',
50+
'data' => '{}',
51+
]);
52+
});
53+
4154
it('can unsubscribe from a channel', function () {
4255
$this->pusher->handle(
4356
$this->connection,

0 commit comments

Comments
 (0)