Apply fixes from StyleCI (#463)
This commit is contained in:
parent
04ff39d75e
commit
b1e6b6ecc5
|
|
@ -17,142 +17,142 @@ class ChannelReplicationTest extends TestCase
|
|||
$this->runOnlyOnRedisReplication();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_clients_can_subscribe_to_channels()
|
||||
{
|
||||
$connection = $this->getWebSocketConnection();
|
||||
/** @test */
|
||||
public function replication_clients_can_subscribe_to_channels()
|
||||
{
|
||||
$connection = $this->getWebSocketConnection();
|
||||
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:subscribe',
|
||||
'data' => [
|
||||
'channel' => 'basic-channel',
|
||||
],
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:subscribe',
|
||||
'data' => [
|
||||
'channel' => 'basic-channel',
|
||||
],
|
||||
]));
|
||||
|
||||
$this->pusherServer->onOpen($connection);
|
||||
$this->pusherServer->onOpen($connection);
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$connection->assertSentEvent('pusher_internal:subscription_succeeded', [
|
||||
'channel' => 'basic-channel',
|
||||
]);
|
||||
}
|
||||
$connection->assertSentEvent('pusher_internal:subscription_succeeded', [
|
||||
'channel' => 'basic-channel',
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_clients_can_unsubscribe_from_channels()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
/** @test */
|
||||
public function replication_clients_can_unsubscribe_from_channels()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$channel = $this->getChannel($connection, 'test-channel');
|
||||
$channel = $this->getChannel($connection, 'test-channel');
|
||||
|
||||
$this->assertTrue($channel->hasConnections());
|
||||
$this->assertTrue($channel->hasConnections());
|
||||
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:unsubscribe',
|
||||
'data' => [
|
||||
'channel' => 'test-channel',
|
||||
],
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:unsubscribe',
|
||||
'data' => [
|
||||
'channel' => 'test-channel',
|
||||
],
|
||||
]));
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$this->assertFalse($channel->hasConnections());
|
||||
}
|
||||
$this->assertFalse($channel->hasConnections());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_a_client_cannot_broadcast_to_other_clients_by_default()
|
||||
{
|
||||
// One connection inside channel "test-channel".
|
||||
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
/** @test */
|
||||
public function replication_a_client_cannot_broadcast_to_other_clients_by_default()
|
||||
{
|
||||
// One connection inside channel "test-channel".
|
||||
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
|
||||
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$existingConnection->assertNotSentEvent('client-test');
|
||||
}
|
||||
$existingConnection->assertNotSentEvent('client-test');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_a_client_can_be_enabled_to_broadcast_to_other_clients()
|
||||
{
|
||||
config()->set('websockets.apps.0.enable_client_messages', true);
|
||||
/** @test */
|
||||
public function replication_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']);
|
||||
// One connection inside channel "test-channel".
|
||||
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
|
||||
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$existingConnection->assertSentEvent('client-test');
|
||||
}
|
||||
$existingConnection->assertSentEvent('client-test');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_closed_connections_get_removed_from_all_connected_channels()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel-1', 'test-channel-2']);
|
||||
/** @test */
|
||||
public function replication_closed_connections_get_removed_from_all_connected_channels()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection(['test-channel-1', 'test-channel-2']);
|
||||
|
||||
$channel1 = $this->getChannel($connection, 'test-channel-1');
|
||||
$channel2 = $this->getChannel($connection, 'test-channel-2');
|
||||
$channel1 = $this->getChannel($connection, 'test-channel-1');
|
||||
$channel2 = $this->getChannel($connection, 'test-channel-2');
|
||||
|
||||
$this->assertTrue($channel1->hasConnections());
|
||||
$this->assertTrue($channel2->hasConnections());
|
||||
$this->assertTrue($channel1->hasConnections());
|
||||
$this->assertTrue($channel2->hasConnections());
|
||||
|
||||
$this->pusherServer->onClose($connection);
|
||||
$this->pusherServer->onClose($connection);
|
||||
|
||||
$this->assertFalse($channel1->hasConnections());
|
||||
$this->assertFalse($channel2->hasConnections());
|
||||
}
|
||||
$this->assertFalse($channel1->hasConnections());
|
||||
$this->assertFalse($channel2->hasConnections());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_channels_can_broadcast_messages_to_all_connections()
|
||||
{
|
||||
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
/** @test */
|
||||
public function replication_channels_can_broadcast_messages_to_all_connections()
|
||||
{
|
||||
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$channel = $this->getChannel($connection1, 'test-channel');
|
||||
$channel = $this->getChannel($connection1, 'test-channel');
|
||||
|
||||
$channel->broadcast([
|
||||
'event' => 'broadcasted-event',
|
||||
'channel' => 'test-channel',
|
||||
]);
|
||||
$channel->broadcast([
|
||||
'event' => 'broadcasted-event',
|
||||
'channel' => 'test-channel',
|
||||
]);
|
||||
|
||||
$connection1->assertSentEvent('broadcasted-event');
|
||||
$connection2->assertSentEvent('broadcasted-event');
|
||||
}
|
||||
$connection1->assertSentEvent('broadcasted-event');
|
||||
$connection2->assertSentEvent('broadcasted-event');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_channels_can_broadcast_messages_to_all_connections_except_the_given_connection()
|
||||
{
|
||||
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
/** @test */
|
||||
public function replication_channels_can_broadcast_messages_to_all_connections_except_the_given_connection()
|
||||
{
|
||||
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
|
||||
|
||||
$channel = $this->getChannel($connection1, 'test-channel');
|
||||
$channel = $this->getChannel($connection1, 'test-channel');
|
||||
|
||||
$channel->broadcastToOthers($connection1, (object) [
|
||||
'event' => 'broadcasted-event',
|
||||
'channel' => 'test-channel',
|
||||
]);
|
||||
$channel->broadcastToOthers($connection1, (object) [
|
||||
'event' => 'broadcasted-event',
|
||||
'channel' => 'test-channel',
|
||||
]);
|
||||
|
||||
$connection1->assertNotSentEvent('broadcasted-event');
|
||||
$connection2->assertSentEvent('broadcasted-event');
|
||||
}
|
||||
$connection1->assertNotSentEvent('broadcasted-event');
|
||||
$connection2->assertSentEvent('broadcasted-event');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function replication_it_responds_correctly_to_the_ping_message()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection();
|
||||
/** @test */
|
||||
public function replication_it_responds_correctly_to_the_ping_message()
|
||||
{
|
||||
$connection = $this->getConnectedWebSocketConnection();
|
||||
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:ping',
|
||||
]));
|
||||
$message = new Message(json_encode([
|
||||
'event' => 'pusher:ping',
|
||||
]));
|
||||
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
$this->pusherServer->onMessage($connection, $message);
|
||||
|
||||
$connection->assertSentEvent('pusher:pong');
|
||||
}
|
||||
$connection->assertSentEvent('pusher:pong');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use BeyondCode\LaravelWebSockets\Tests\Mocks\Message;
|
|||
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
||||
use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\InvalidSignature;
|
||||
|
||||
|
||||
class PrivateChannelReplicationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
|||
use GuzzleHttp\Psr7\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pusher\Pusher;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class FetchChannelsReplicationTest extends TestCase
|
||||
{
|
||||
|
|
@ -55,7 +54,6 @@ class FetchChannelsReplicationTest extends TestCase
|
|||
->assertCalled('multi')
|
||||
->assertCalledWithArgs('hlen', ['1234:presence-channel'])
|
||||
->assertCalled('exec');
|
||||
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
|
|||
Loading…
Reference in New Issue