Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit c2cec0e

Browse files
committed
Merge branch 'tests/redis-connector' of github.com:beyondcode/laravel-websockets into tests/redis-connector
2 parents 9e7e873 + b1e6b6e commit c2cec0e

File tree

3 files changed

+99
-102
lines changed

3 files changed

+99
-102
lines changed

tests/Channels/ChannelReplicationTest.php

Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,142 +17,142 @@ public function setUp(): void
1717
$this->runOnlyOnRedisReplication();
1818
}
1919

20-
/** @test */
21-
public function replication_clients_can_subscribe_to_channels()
22-
{
23-
$connection = $this->getWebSocketConnection();
24-
25-
$message = new Message(json_encode([
26-
'event' => 'pusher:subscribe',
27-
'data' => [
28-
'channel' => 'basic-channel',
29-
],
20+
/** @test */
21+
public function replication_clients_can_subscribe_to_channels()
22+
{
23+
$connection = $this->getWebSocketConnection();
24+
25+
$message = new Message(json_encode([
26+
'event' => 'pusher:subscribe',
27+
'data' => [
28+
'channel' => 'basic-channel',
29+
],
3030
]));
3131

32-
$this->pusherServer->onOpen($connection);
32+
$this->pusherServer->onOpen($connection);
3333

34-
$this->pusherServer->onMessage($connection, $message);
34+
$this->pusherServer->onMessage($connection, $message);
3535

36-
$connection->assertSentEvent('pusher_internal:subscription_succeeded', [
37-
'channel' => 'basic-channel',
38-
]);
39-
}
36+
$connection->assertSentEvent('pusher_internal:subscription_succeeded', [
37+
'channel' => 'basic-channel',
38+
]);
39+
}
4040

41-
/** @test */
42-
public function replication_clients_can_unsubscribe_from_channels()
43-
{
44-
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
41+
/** @test */
42+
public function replication_clients_can_unsubscribe_from_channels()
43+
{
44+
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
4545

46-
$channel = $this->getChannel($connection, 'test-channel');
46+
$channel = $this->getChannel($connection, 'test-channel');
4747

48-
$this->assertTrue($channel->hasConnections());
48+
$this->assertTrue($channel->hasConnections());
4949

50-
$message = new Message(json_encode([
51-
'event' => 'pusher:unsubscribe',
52-
'data' => [
53-
'channel' => 'test-channel',
54-
],
50+
$message = new Message(json_encode([
51+
'event' => 'pusher:unsubscribe',
52+
'data' => [
53+
'channel' => 'test-channel',
54+
],
5555
]));
5656

57-
$this->pusherServer->onMessage($connection, $message);
57+
$this->pusherServer->onMessage($connection, $message);
5858

59-
$this->assertFalse($channel->hasConnections());
60-
}
59+
$this->assertFalse($channel->hasConnections());
60+
}
6161

62-
/** @test */
63-
public function replication_a_client_cannot_broadcast_to_other_clients_by_default()
64-
{
65-
// One connection inside channel "test-channel".
66-
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
62+
/** @test */
63+
public function replication_a_client_cannot_broadcast_to_other_clients_by_default()
64+
{
65+
// One connection inside channel "test-channel".
66+
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
6767

68-
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
68+
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
6969

70-
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
70+
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
7171

72-
$this->pusherServer->onMessage($connection, $message);
72+
$this->pusherServer->onMessage($connection, $message);
7373

74-
$existingConnection->assertNotSentEvent('client-test');
75-
}
74+
$existingConnection->assertNotSentEvent('client-test');
75+
}
7676

77-
/** @test */
78-
public function replication_a_client_can_be_enabled_to_broadcast_to_other_clients()
79-
{
80-
config()->set('websockets.apps.0.enable_client_messages', true);
77+
/** @test */
78+
public function replication_a_client_can_be_enabled_to_broadcast_to_other_clients()
79+
{
80+
config()->set('websockets.apps.0.enable_client_messages', true);
8181

82-
// One connection inside channel "test-channel".
83-
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
82+
// One connection inside channel "test-channel".
83+
$existingConnection = $this->getConnectedWebSocketConnection(['test-channel']);
8484

85-
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
85+
$connection = $this->getConnectedWebSocketConnection(['test-channel']);
8686

87-
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
87+
$message = new Message('{"event": "client-test", "data": {}, "channel": "test-channel"}');
8888

89-
$this->pusherServer->onMessage($connection, $message);
89+
$this->pusherServer->onMessage($connection, $message);
9090

91-
$existingConnection->assertSentEvent('client-test');
92-
}
91+
$existingConnection->assertSentEvent('client-test');
92+
}
9393

94-
/** @test */
95-
public function replication_closed_connections_get_removed_from_all_connected_channels()
96-
{
97-
$connection = $this->getConnectedWebSocketConnection(['test-channel-1', 'test-channel-2']);
94+
/** @test */
95+
public function replication_closed_connections_get_removed_from_all_connected_channels()
96+
{
97+
$connection = $this->getConnectedWebSocketConnection(['test-channel-1', 'test-channel-2']);
9898

99-
$channel1 = $this->getChannel($connection, 'test-channel-1');
100-
$channel2 = $this->getChannel($connection, 'test-channel-2');
99+
$channel1 = $this->getChannel($connection, 'test-channel-1');
100+
$channel2 = $this->getChannel($connection, 'test-channel-2');
101101

102-
$this->assertTrue($channel1->hasConnections());
103-
$this->assertTrue($channel2->hasConnections());
102+
$this->assertTrue($channel1->hasConnections());
103+
$this->assertTrue($channel2->hasConnections());
104104

105-
$this->pusherServer->onClose($connection);
105+
$this->pusherServer->onClose($connection);
106106

107-
$this->assertFalse($channel1->hasConnections());
108-
$this->assertFalse($channel2->hasConnections());
109-
}
107+
$this->assertFalse($channel1->hasConnections());
108+
$this->assertFalse($channel2->hasConnections());
109+
}
110110

111-
/** @test */
112-
public function replication_channels_can_broadcast_messages_to_all_connections()
113-
{
114-
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
115-
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
111+
/** @test */
112+
public function replication_channels_can_broadcast_messages_to_all_connections()
113+
{
114+
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
115+
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
116116

117-
$channel = $this->getChannel($connection1, 'test-channel');
117+
$channel = $this->getChannel($connection1, 'test-channel');
118118

119-
$channel->broadcast([
120-
'event' => 'broadcasted-event',
121-
'channel' => 'test-channel',
122-
]);
119+
$channel->broadcast([
120+
'event' => 'broadcasted-event',
121+
'channel' => 'test-channel',
122+
]);
123123

124-
$connection1->assertSentEvent('broadcasted-event');
125-
$connection2->assertSentEvent('broadcasted-event');
126-
}
124+
$connection1->assertSentEvent('broadcasted-event');
125+
$connection2->assertSentEvent('broadcasted-event');
126+
}
127127

128-
/** @test */
129-
public function replication_channels_can_broadcast_messages_to_all_connections_except_the_given_connection()
130-
{
131-
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
132-
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
128+
/** @test */
129+
public function replication_channels_can_broadcast_messages_to_all_connections_except_the_given_connection()
130+
{
131+
$connection1 = $this->getConnectedWebSocketConnection(['test-channel']);
132+
$connection2 = $this->getConnectedWebSocketConnection(['test-channel']);
133133

134-
$channel = $this->getChannel($connection1, 'test-channel');
134+
$channel = $this->getChannel($connection1, 'test-channel');
135135

136-
$channel->broadcastToOthers($connection1, (object) [
137-
'event' => 'broadcasted-event',
138-
'channel' => 'test-channel',
139-
]);
136+
$channel->broadcastToOthers($connection1, (object) [
137+
'event' => 'broadcasted-event',
138+
'channel' => 'test-channel',
139+
]);
140140

141-
$connection1->assertNotSentEvent('broadcasted-event');
142-
$connection2->assertSentEvent('broadcasted-event');
143-
}
141+
$connection1->assertNotSentEvent('broadcasted-event');
142+
$connection2->assertSentEvent('broadcasted-event');
143+
}
144144

145-
/** @test */
146-
public function replication_it_responds_correctly_to_the_ping_message()
147-
{
148-
$connection = $this->getConnectedWebSocketConnection();
145+
/** @test */
146+
public function replication_it_responds_correctly_to_the_ping_message()
147+
{
148+
$connection = $this->getConnectedWebSocketConnection();
149149

150-
$message = new Message(json_encode([
151-
'event' => 'pusher:ping',
152-
]));
150+
$message = new Message(json_encode([
151+
'event' => 'pusher:ping',
152+
]));
153153

154-
$this->pusherServer->onMessage($connection, $message);
154+
$this->pusherServer->onMessage($connection, $message);
155155

156-
$connection->assertSentEvent('pusher:pong');
157-
}
156+
$connection->assertSentEvent('pusher:pong');
157+
}
158158
}

tests/Channels/PrivateChannelReplicationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use BeyondCode\LaravelWebSockets\Tests\TestCase;
77
use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\InvalidSignature;
88

9-
109
class PrivateChannelReplicationTest extends TestCase
1110
{
1211
/**

tests/HttpApi/FetchChannelsReplicationTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use GuzzleHttp\Psr7\Request;
99
use Illuminate\Http\JsonResponse;
1010
use Pusher\Pusher;
11-
use Symfony\Component\HttpKernel\Exception\HttpException;
1211

1312
class FetchChannelsReplicationTest extends TestCase
1413
{
@@ -55,7 +54,6 @@ public function replication_it_returns_the_channel_information()
5554
->assertCalled('multi')
5655
->assertCalledWithArgs('hlen', ['1234:presence-channel'])
5756
->assertCalled('exec');
58-
5957
}
6058

6159
/** @test */

0 commit comments

Comments
 (0)