From 89ace081399f197de46c9b5e7466611da62f4add Mon Sep 17 00:00:00 2001 From: freek Date: Sat, 1 Dec 2018 16:24:36 +0100 Subject: [PATCH] disable client messages by default --- config/websockets.php | 2 +- tests/Channels/ChannelTest.php | 36 +++++++++---------- .../ClientProviders/ConfigAppProviderTest.php | 1 + tests/TestCase.php | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/config/websockets.php b/config/websockets.php index 05ab579..b3aedfe 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -17,7 +17,7 @@ return [ 'name' => env('APP_NAME'), 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), - 'enable_client_messages' => true, + 'enable_client_messages' => false, ], ], diff --git a/tests/Channels/ChannelTest.php b/tests/Channels/ChannelTest.php index 60a654a..f7e3ca5 100644 --- a/tests/Channels/ChannelTest.php +++ b/tests/Channels/ChannelTest.php @@ -29,7 +29,7 @@ class ChannelTest extends TestCase } /** @test */ - public function client_messages_get_broadcasted_to_other_clients_in_the_same_channel() + public function a_client_cannot_broadcast_to_other_clients_by_default() { // One connection inside channel "test-channel". $existingConnection = $this->getConnectedWebSocketConnection(['test-channel']); @@ -40,26 +40,26 @@ class ChannelTest extends TestCase $this->pusherServer->onMessage($connection, $message); - $existingConnection->assertSentEvent('client-test'); - } - - /** @test */ - public function client_messages_will_not_get_broadcasted_to_other_clients_if_client_messages_are_not_enabled() - { - config()->set('websockets.apps.0.enable_client_messages', false); - - // One connection inside channel "test-channel". - $existingConnection = $this->getConnectedWebSocketConnection(['test-channel']); - - $connection = $this->getConnectedWebSocketConnection(['test-channel']); - - $message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}'); - - $this->pusherServer->onMessage($connection, $message); - $existingConnection->assertNotSentEvent('client-test'); } + /** @test */ + public function a_client_can_be_enabled_to_broadcast_to_other_clients() + { + config()->set('websockets.apps.0.enable_client_messages', true); + + // One connection inside channel "test-channel". + $existingConnection = $this->getConnectedWebSocketConnection(['test-channel']); + + $connection = $this->getConnectedWebSocketConnection(['test-channel']); + + $message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}'); + + $this->pusherServer->onMessage($connection, $message); + + $existingConnection->assertSentEvent('client-test'); + } + /** @test */ public function closed_connections_get_removed_from_all_connected_channels() { diff --git a/tests/ClientProviders/ConfigAppProviderTest.php b/tests/ClientProviders/ConfigAppProviderTest.php index bcbf7fd..84182d0 100644 --- a/tests/ClientProviders/ConfigAppProviderTest.php +++ b/tests/ClientProviders/ConfigAppProviderTest.php @@ -31,5 +31,6 @@ class ConfigAppProviderTest extends TestCase $this->assertEquals(1234, $app->id); $this->assertEquals('TestKey', $app->key); $this->assertEquals('TestSecret', $app->secret); + $this->assertFalse($app->clientMessagesEnabled); } } \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index b6115f6..1d3d965 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -40,7 +40,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase 'id' => 1234, 'key' => 'TestKey', 'secret' => 'TestSecret', - 'enable_client_messages' => true, + 'enable_client_messages' => false, ], ]); }