Skip to content

Commit

Permalink
Apply fixes from StyleCI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
morloderex authored Feb 12, 2018
1 parent ac970f8 commit 3281813
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
9 changes: 4 additions & 5 deletions src/Broadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function auth($request)
{
$channels = [];

foreach($request->channel_name as $channel) {
foreach ($request->channel_name as $channel) {
if (Str::startsWith($channel, ['private-', 'presence-']) && ! $request->user()) {
$channels[$channel] = [
'status' => Response::HTTP_FORBIDDEN,
Expand All @@ -32,11 +32,11 @@ public function auth($request)
if ($result) {
$channels[$channel] = [
'status' => Response::HTTP_OK,
'data' => $this->validAuthenticationBatchedResponse($request, $channel, $result)
'data' => $this->validAuthenticationBatchedResponse($request, $channel, $result),
];
} else {
$channels[$channel] = [
'status' => Response::HTTP_FORBIDDEN
'status' => Response::HTTP_FORBIDDEN,
];
}
}
Expand Down Expand Up @@ -92,7 +92,6 @@ public function validAuthenticationBatchedResponse($request, $channel, $result)
*/
public function validAuthenticationResponse($request, $result)
{

}

/**
Expand All @@ -105,4 +104,4 @@ protected function parseChannel($channel)
? Str::replaceFirst('private-', '', $channel)
: Str::replaceFirst('presence-', '', $channel);
}
}
}
7 changes: 2 additions & 5 deletions src/Providers/BatchedPusherProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@

class BatchedPusherProvider extends ServiceProvider
{
/**
*
*/
public function boot()
{
Broadcast::extend('BatchedPusher', function($app, $config) {
Broadcast::extend('BatchedPusher', function ($app, $config) {
return new Broadcaster(
new Pusher($config['key'], $config['secret'],
$config['app_id'], $config['options'] ?? [])
);
});
}
}
}
26 changes: 13 additions & 13 deletions test/Feature/PusherBatchProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Mockery;
use Pusher\Pusher;
use Morloderex\PusherBatch\Broadcaster;
use Orchestra\Testbench\TestCase;
use Illuminate\Foundation\Auth\User;
use Morloderex\PusherBatch\Broadcaster;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Broadcasting\BroadcastController;
use Illuminate\Foundation\Testing\RefreshDatabase;
Expand All @@ -27,24 +27,25 @@ public function setUp()

protected function getEnvironmentSetUp($app)
{
$app['router']->post('/broadcasting/auth', BroadcastController::class . '@authenticate');
$app['router']->post('/broadcasting/auth', BroadcastController::class.'@authenticate');
}

public function test_broadcast_driver()
{
$this->withoutExceptionHandling();


$response = $this->actingAs(
tap(new User, function ($user) {$user->id = 1;})
tap(new User, function ($user) {
$user->id = 1;
})
)->call('POST', 'broadcasting/auth', [
'socket_id' => 'testing',
'channel_name' => [
'private-post.1',
'private-post.2',
'presence-user.1',
'presence-user.2',
]
],
]);

$response->assertStatus(200);
Expand All @@ -56,26 +57,26 @@ public function test_broadcast_driver()
'status' => 200,
'data' => [
'auth' => 'testing',
]
],
],
'presence-user.1' => [
'status' => 200,
'data' => [
'auth' => 'testing',
'channel_data' => [
'user_id' => 1,
'user_info' => 1
]
]
'user_info' => 1,
],
],
],
'presence-user.2' => [
'status' => 403,
]
],
]);
}

/**
* Register my provider
* Register my provider.
*
* @param \Illuminate\Foundation\Application $app
* @return array
Expand All @@ -99,7 +100,6 @@ protected function setUpBroadcaster()
$pusher->shouldNotReceive('presence_auth')
->with('presence-user.2', 'testing', 1, true);


$pusher->shouldReceive('socket_auth')
->once()
->with('private-post.2', 'testing')
Expand Down Expand Up @@ -132,4 +132,4 @@ protected function listenOnBroadcastRoutes()
return false;
});
}
}
}

0 comments on commit 3281813

Please sign in to comment.