diff --git a/tests/Channels/ChannelTest.php b/tests/Channels/ChannelTest.php index f7e3ca5..82ff1fe 100644 --- a/tests/Channels/ChannelTest.php +++ b/tests/Channels/ChannelTest.php @@ -28,6 +28,27 @@ class ChannelTest extends TestCase ]); } + /** @test */ + public function clients_can_unsubscribe_from_channels() + { + $connection = $this->getConnectedWebSocketConnection(['test-channel']); + + $channel = $this->getChannel($connection, 'test-channel'); + + $this->assertTrue($channel->hasConnections()); + + $message = new Message(json_encode([ + 'event' => 'pusher:unsubscribe', + 'data' => [ + 'channel' => 'test-channel' + ], + ])); + + $this->pusherServer->onMessage($connection, $message); + + $this->assertFalse($channel->hasConnections()); + } + /** @test */ public function a_client_cannot_broadcast_to_other_clients_by_default() {