@@ -17,142 +17,142 @@ public function setUp(): void
17
17
$ this ->runOnlyOnRedisReplication ();
18
18
}
19
19
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
+ ],
30
30
]));
31
31
32
- $ this ->pusherServer ->onOpen ($ connection );
32
+ $ this ->pusherServer ->onOpen ($ connection );
33
33
34
- $ this ->pusherServer ->onMessage ($ connection , $ message );
34
+ $ this ->pusherServer ->onMessage ($ connection , $ message );
35
35
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
+ }
40
40
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 ' ]);
45
45
46
- $ channel = $ this ->getChannel ($ connection , 'test-channel ' );
46
+ $ channel = $ this ->getChannel ($ connection , 'test-channel ' );
47
47
48
- $ this ->assertTrue ($ channel ->hasConnections ());
48
+ $ this ->assertTrue ($ channel ->hasConnections ());
49
49
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
+ ],
55
55
]));
56
56
57
- $ this ->pusherServer ->onMessage ($ connection , $ message );
57
+ $ this ->pusherServer ->onMessage ($ connection , $ message );
58
58
59
- $ this ->assertFalse ($ channel ->hasConnections ());
60
- }
59
+ $ this ->assertFalse ($ channel ->hasConnections ());
60
+ }
61
61
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 ' ]);
67
67
68
- $ connection = $ this ->getConnectedWebSocketConnection (['test-channel ' ]);
68
+ $ connection = $ this ->getConnectedWebSocketConnection (['test-channel ' ]);
69
69
70
- $ message = new Message ('{"event": "client-test", "data": {}, "channel": "test-channel"} ' );
70
+ $ message = new Message ('{"event": "client-test", "data": {}, "channel": "test-channel"} ' );
71
71
72
- $ this ->pusherServer ->onMessage ($ connection , $ message );
72
+ $ this ->pusherServer ->onMessage ($ connection , $ message );
73
73
74
- $ existingConnection ->assertNotSentEvent ('client-test ' );
75
- }
74
+ $ existingConnection ->assertNotSentEvent ('client-test ' );
75
+ }
76
76
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 );
81
81
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 ' ]);
84
84
85
- $ connection = $ this ->getConnectedWebSocketConnection (['test-channel ' ]);
85
+ $ connection = $ this ->getConnectedWebSocketConnection (['test-channel ' ]);
86
86
87
- $ message = new Message ('{"event": "client-test", "data": {}, "channel": "test-channel"} ' );
87
+ $ message = new Message ('{"event": "client-test", "data": {}, "channel": "test-channel"} ' );
88
88
89
- $ this ->pusherServer ->onMessage ($ connection , $ message );
89
+ $ this ->pusherServer ->onMessage ($ connection , $ message );
90
90
91
- $ existingConnection ->assertSentEvent ('client-test ' );
92
- }
91
+ $ existingConnection ->assertSentEvent ('client-test ' );
92
+ }
93
93
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 ' ]);
98
98
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 ' );
101
101
102
- $ this ->assertTrue ($ channel1 ->hasConnections ());
103
- $ this ->assertTrue ($ channel2 ->hasConnections ());
102
+ $ this ->assertTrue ($ channel1 ->hasConnections ());
103
+ $ this ->assertTrue ($ channel2 ->hasConnections ());
104
104
105
- $ this ->pusherServer ->onClose ($ connection );
105
+ $ this ->pusherServer ->onClose ($ connection );
106
106
107
- $ this ->assertFalse ($ channel1 ->hasConnections ());
108
- $ this ->assertFalse ($ channel2 ->hasConnections ());
109
- }
107
+ $ this ->assertFalse ($ channel1 ->hasConnections ());
108
+ $ this ->assertFalse ($ channel2 ->hasConnections ());
109
+ }
110
110
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 ' ]);
116
116
117
- $ channel = $ this ->getChannel ($ connection1 , 'test-channel ' );
117
+ $ channel = $ this ->getChannel ($ connection1 , 'test-channel ' );
118
118
119
- $ channel ->broadcast ([
120
- 'event ' => 'broadcasted-event ' ,
121
- 'channel ' => 'test-channel ' ,
122
- ]);
119
+ $ channel ->broadcast ([
120
+ 'event ' => 'broadcasted-event ' ,
121
+ 'channel ' => 'test-channel ' ,
122
+ ]);
123
123
124
- $ connection1 ->assertSentEvent ('broadcasted-event ' );
125
- $ connection2 ->assertSentEvent ('broadcasted-event ' );
126
- }
124
+ $ connection1 ->assertSentEvent ('broadcasted-event ' );
125
+ $ connection2 ->assertSentEvent ('broadcasted-event ' );
126
+ }
127
127
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 ' ]);
133
133
134
- $ channel = $ this ->getChannel ($ connection1 , 'test-channel ' );
134
+ $ channel = $ this ->getChannel ($ connection1 , 'test-channel ' );
135
135
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
+ ]);
140
140
141
- $ connection1 ->assertNotSentEvent ('broadcasted-event ' );
142
- $ connection2 ->assertSentEvent ('broadcasted-event ' );
143
- }
141
+ $ connection1 ->assertNotSentEvent ('broadcasted-event ' );
142
+ $ connection2 ->assertSentEvent ('broadcasted-event ' );
143
+ }
144
144
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 ();
149
149
150
- $ message = new Message (json_encode ([
151
- 'event ' => 'pusher:ping ' ,
152
- ]));
150
+ $ message = new Message (json_encode ([
151
+ 'event ' => 'pusher:ping ' ,
152
+ ]));
153
153
154
- $ this ->pusherServer ->onMessage ($ connection , $ message );
154
+ $ this ->pusherServer ->onMessage ($ connection , $ message );
155
155
156
- $ connection ->assertSentEvent ('pusher:pong ' );
157
- }
156
+ $ connection ->assertSentEvent ('pusher:pong ' );
157
+ }
158
158
}
0 commit comments