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

Commit fcb3a53

Browse files
authored
Apply fixes from StyleCI (#692)
1 parent 1f0458c commit fcb3a53

9 files changed

+24
-39
lines changed

src/API/Controller.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ protected function handleRequest(ConnectionInterface $connection)
184184
$this->ensureValidSignature($app, $laravelRequest);
185185
} catch (HttpException $exception) {
186186
$this->onError($connection, $exception);
187+
187188
return;
188189
}
189190

@@ -192,6 +193,7 @@ protected function handleRequest(ConnectionInterface $connection)
192193
$response = $this($laravelRequest);
193194
} catch (HttpException $exception) {
194195
$this->onError($connection, $exception);
196+
195197
return;
196198
}
197199

@@ -206,6 +208,7 @@ protected function handleRequest(ConnectionInterface $connection)
206208

207209
if ($response instanceof HttpException) {
208210
$this->onError($connection, $response);
211+
209212
return;
210213
}
211214

src/API/TriggerEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function __invoke(Request $request)
4040

4141
if ($channel) {
4242
$channel->broadcastLocallyToEveryoneExcept(
43-
(object)$payload,
43+
(object) $payload,
4444
$request->socket_id,
4545
$request->appId
4646
);
4747
}
4848

4949
$this->channelManager->broadcastAcrossServers(
50-
$request->appId, $request->socket_id, $channelName, (object)$payload
50+
$request->appId, $request->socket_id, $channelName, (object) $payload
5151
);
5252

5353
$deferred = new Deferred();

tests/ConnectionTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace BeyondCode\LaravelWebSockets\Test;
44

5-
use BeyondCode\LaravelWebSockets\Server\Exceptions\OriginNotAllowed;
65
use BeyondCode\LaravelWebSockets\Server\Exceptions\UnknownAppKey;
76

87
class ConnectionTest extends TestCase
@@ -12,15 +11,15 @@ public function test_cannot_connect_with_a_wrong_app_key()
1211
$this->startServer();
1312

1413
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'NonWorkingKey'));
15-
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string)$response);
14+
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
1615
}
1716

1817
public function test_unconnected_app_cannot_store_statistics()
1918
{
2019
$this->startServer();
2120

2221
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'NonWorkingKey'));
23-
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string)$response);
22+
$this->assertSame('{"event":"pusher:error","data":{"message":"Could not find app key `NonWorkingKey`.","code":4001}}', (string) $response);
2423

2524
$count = $this->await($this->statisticsCollector->getStatistics());
2625
$this->assertCount(0, $count);
@@ -31,15 +30,15 @@ public function test_origin_validation_should_fail_for_no_origin()
3130
$this->startServer();
3231

3332
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'TestOrigin'));
34-
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string)$response);
33+
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
3534
}
3635

3736
public function test_origin_validation_should_fail_for_wrong_origin()
3837
{
3938
$this->startServer();
4039

4140
$response = $this->await($this->joinWebSocketServer(['public-channel'], 'TestOrigin', ['Origin' => 'https://google.ro']));
42-
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string)$response);
41+
$this->assertSame('{"event":"pusher:error","data":{"message":"The origin is not allowed for `TestOrigin`.","code":4009}}', (string) $response);
4342
}
4443

4544
public function test_origin_validation_should_pass_for_the_right_origin()

tests/FetchChannelTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use GuzzleHttp\Psr7\Request;
77
use Illuminate\Http\JsonResponse;
88
use Pusher\Pusher;
9-
use Symfony\Component\HttpKernel\Exception\HttpException;
109

1110
class FetchChannelTest extends TestCase
1211
{
@@ -22,7 +21,7 @@ public function test_invalid_signatures_can_not_access_the_api()
2221

2322
$request = new Request('GET', "{$requestPath}?{$queryString}");
2423

25-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
24+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
2625

2726
$this->assertSame(401, $response->getStatusCode());
2827
$this->assertSame('{"error":"Invalid auth signature provided."}', $response->getBody()->getContents());
@@ -102,7 +101,7 @@ public function test_it_returns_404_for_invalid_channels()
102101

103102
$queryString = Pusher::build_auth_query_string('TestKey', 'TestSecret', 'GET', $requestPath);
104103

105-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
104+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
106105

107106
$this->assertSame(404, $response->getStatusCode());
108107
$this->assertSame('{"error":"Unknown channel `invalid-channel`."}', $response->getBody()->getContents());

tests/FetchChannelsTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use GuzzleHttp\Psr7\Request;
77
use Illuminate\Http\JsonResponse;
88
use Pusher\Pusher;
9-
use Symfony\Component\HttpKernel\Exception\HttpException;
109

1110
class FetchChannelsTest extends TestCase
1211
{
@@ -22,7 +21,7 @@ public function test_invalid_signatures_can_not_access_the_api()
2221

2322
$request = new Request('GET', "{$requestPath}?{$queryString}");
2423

25-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
24+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
2625

2726
$this->assertSame(401, $response->getStatusCode());
2827
$this->assertSame('{"error":"Invalid auth signature provided."}', $response->getBody()->getContents());
@@ -147,7 +146,7 @@ public function test_can_not_get_non_presence_channel_user_count()
147146
'info' => 'user_count',
148147
]);
149148

150-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
149+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
151150

152151
$this->assertSame(400, $response->getStatusCode());
153152
$this->assertSame('{"error":"Request must be limited to presence channels in order to fetch user_count"}', $response->getBody()->getContents());

tests/FetchUsersTest.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@
33
namespace BeyondCode\LaravelWebSockets\Test;
44

55
use BeyondCode\LaravelWebSockets\API\FetchUsers;
6-
use BeyondCode\LaravelWebSockets\Facades\WebSocketRouter;
7-
use BeyondCode\LaravelWebSockets\Server\Loggers\HttpLogger;
8-
use BeyondCode\LaravelWebSockets\Server\Loggers\WebSocketsLogger;
9-
use BeyondCode\LaravelWebSockets\ServerFactory;
10-
use Clue\React\Buzz\Browser;
11-
use Clue\React\Buzz\Message\ResponseException;
126
use GuzzleHttp\Psr7\Request;
13-
use Illuminate\Support\Facades\Http;
147
use Pusher\Pusher;
15-
use Symfony\Component\Console\Output\BufferedOutput;
16-
use Symfony\Component\HttpKernel\Exception\HttpException;
17-
use function Clue\React\Block\await;
188

199
class FetchUsersTest extends TestCase
2010
{
@@ -28,7 +18,7 @@ public function test_invalid_signatures_can_not_access_the_api()
2818
'TestKey', 'InvalidSecret', 'GET', $requestPath
2919
);
3020

31-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
21+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
3222

3323
$this->assertSame(401, $response->getStatusCode());
3424
$this->assertSame('{"error":"Invalid auth signature provided."}', $response->getBody()->getContents());
@@ -44,7 +34,7 @@ public function test_it_only_returns_data_for_presence_channels()
4434
'TestKey', 'TestSecret', 'GET', $requestPath
4535
);
4636

47-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
37+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
4838

4939
$this->assertSame(400, $response->getStatusCode());
5040
$this->assertSame('{"error":"Invalid presence channel `my-channel`"}', $response->getBody()->getContents());
@@ -60,7 +50,7 @@ public function test_it_returns_400_for_invalid_channels()
6050
'TestKey', 'TestSecret', 'GET', $requestPath
6151
);
6252

63-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
53+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
6454

6555
$this->assertSame(400, $response->getStatusCode());
6656
$this->assertSame('{"error":"Invalid presence channel `invalid-channel`"}', $response->getBody()->getContents());

tests/PublicChannelTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ public function test_it_fires_the_event_to_public_channel()
222222
],
223223
);
224224

225-
$response = $this->await($this->browser->post('http://localhost:4000' . "{$requestPath}?{$queryString}"));
225+
$response = $this->await($this->browser->post('http://localhost:4000'."{$requestPath}?{$queryString}"));
226226

227-
$this->assertSame([], json_decode((string)$response->getBody(), true));
227+
$this->assertSame([], json_decode((string) $response->getBody(), true));
228228

229229
$this->statisticsCollector
230230
->getAppStatistics('1234')

tests/TestCase.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use BeyondCode\LaravelWebSockets\Server\Loggers\HttpLogger;
1111
use BeyondCode\LaravelWebSockets\Server\Loggers\WebSocketsLogger;
1212
use BeyondCode\LaravelWebSockets\ServerFactory;
13+
use function Clue\React\Block\await;
1314
use Clue\React\Buzz\Browser;
1415
use GuzzleHttp\Psr7\Request;
1516
use Illuminate\Support\Facades\Redis;
@@ -20,23 +21,20 @@
2021
use React\Promise\Deferred;
2122
use React\Promise\PromiseInterface;
2223
use Symfony\Component\Console\Output\BufferedOutput;
23-
use Symfony\Component\Console\Output\ConsoleOutput;
24-
use Symfony\Component\Console\Output\ConsoleOutputInterface;
25-
use function Clue\React\Block\await;
2624

2725
abstract class TestCase extends Orchestra
2826
{
2927
const AWAIT_TIMEOUT = 5.0;
3028

3129
/**
32-
* The test Browser
30+
* The test Browser.
3331
*
3432
* @var \Clue\React\Buzz\Browser
3533
*/
3634
protected $browser;
3735

3836
/**
39-
* The test WebSocket server
37+
* The test WebSocket server.
4038
*
4139
* @var IoServer
4240
*/
@@ -386,8 +384,8 @@ protected function joinWebSocketServer(array $channelsToJoin = [], string $appKe
386384
{
387385
$promise = new Deferred();
388386

389-
\Ratchet\Client\connect("ws://localhost:4000/app/{$appKey}", [], [], $this->loop)->then(function($conn) use ($promise) {
390-
$conn->on('message', function($msg) use ($conn, $promise) {
387+
\Ratchet\Client\connect("ws://localhost:4000/app/{$appKey}", [], [], $this->loop)->then(function ($conn) use ($promise) {
388+
$conn->on('message', function ($msg) use ($promise) {
391389
$promise->resolve($msg);
392390
});
393391
});

tests/TriggerEventTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
namespace BeyondCode\LaravelWebSockets\Test;
44

5-
use BeyondCode\LaravelWebSockets\API\TriggerEvent;
6-
use GuzzleHttp\Psr7\Request;
75
use Pusher\Pusher;
8-
use Symfony\Component\HttpKernel\Exception\HttpException;
96

107
class TriggerEventTest extends TestCase
118
{
@@ -21,7 +18,7 @@ public function test_invalid_signatures_can_not_fire_the_event()
2118
'TestKey', 'InvalidSecret', 'GET', $requestPath
2219
);
2320

24-
$response = $this->await($this->browser->get('http://localhost:4000' . "{$requestPath}?{$queryString}"));
21+
$response = $this->await($this->browser->get('http://localhost:4000'."{$requestPath}?{$queryString}"));
2522

2623
$this->assertSame(405, $response->getStatusCode());
2724
$this->assertSame('', $response->getBody()->getContents());

0 commit comments

Comments
 (0)