wip
This commit is contained in:
parent
96c0eb98d6
commit
b46cfadaa2
|
|
@ -45,7 +45,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
|
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench-browser-kit:${{ matrix.testbench }}" --no-interaction --no-update
|
||||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
|
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
|
||||||
|
|
||||||
- name: Execute tests with Local driver
|
- name: Execute tests with Local driver
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mockery/mockery": "^1.3",
|
"mockery/mockery": "^1.3",
|
||||||
"orchestra/testbench": "3.8.*|^4.0|^5.0",
|
"orchestra/testbench-browser-kit": "^4.0|^5.0",
|
||||||
"phpunit/phpunit": "^8.0|^9.0"
|
"phpunit/phpunit": "^8.0|^9.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class RedisPusherBroadcaster extends Broadcaster
|
||||||
* Create a new broadcaster instance.
|
* Create a new broadcaster instance.
|
||||||
*
|
*
|
||||||
* @param Pusher $pusher
|
* @param Pusher $pusher
|
||||||
* @param $appId
|
* @param mixed $appId
|
||||||
* @param \Illuminate\Contracts\Redis\Factory $redis
|
* @param \Illuminate\Contracts\Redis\Factory $redis
|
||||||
* @param string|null $connection
|
* @param string|null $connection
|
||||||
*/
|
*/
|
||||||
|
|
@ -63,7 +63,6 @@ class RedisPusherBroadcaster extends Broadcaster
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||||
*/
|
*/
|
||||||
public function auth($request)
|
public function auth($request)
|
||||||
|
|
@ -144,7 +143,7 @@ class RedisPusherBroadcaster extends Broadcaster
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ($this->formatChannels($channels) as $channel) {
|
foreach ($this->formatChannels($channels) as $channel) {
|
||||||
$connection->publish("{$this->appId}:$channel", $payload);
|
$connection->publish("{$this->appId}:{$channel}", $payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,13 +118,15 @@ class WebSocketsServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
protected function registerDashboardRoutes()
|
protected function registerDashboardRoutes()
|
||||||
{
|
{
|
||||||
Route::prefix(config('websockets.dashboard.path'))->group(function () {
|
Route::group([
|
||||||
Route::middleware(config('websockets.dashboard.middleware', [AuthorizeDashboard::class]))->group(function () {
|
'prefix' => config('websockets.dashboard.path'),
|
||||||
Route::get('/', ShowDashboard::class);
|
'as' => 'laravel-websockets.',
|
||||||
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
|
'middleware' => config('websockets.dashboard.middleware', [AuthorizeDashboard::class]),
|
||||||
Route::post('auth', AuthenticateDashboard::class);
|
], function () {
|
||||||
Route::post('event', SendMessage::class);
|
Route::get('/', ShowDashboard::class)->name('dashboard');
|
||||||
});
|
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics'])->name('statistics');
|
||||||
|
Route::post('auth', AuthenticateDashboard::class)->name('auth');
|
||||||
|
Route::post('event', SendMessage::class)->name('send');
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -138,7 +140,7 @@ class WebSocketsServiceProvider extends ServiceProvider
|
||||||
protected function registerDashboardGate()
|
protected function registerDashboardGate()
|
||||||
{
|
{
|
||||||
Gate::define('viewWebSocketsDashboard', function ($user = null) {
|
Gate::define('viewWebSocketsDashboard', function ($user = null) {
|
||||||
return $this->app->environment('local');
|
return $this->app->environment(['local', 'testing']);
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeyondCode\LaravelWebSockets\Tests\Dashboard;
|
||||||
|
|
||||||
|
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
||||||
|
|
||||||
|
class DashboardTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @test */
|
||||||
|
public function cant_see_dashboard_without_authorization()
|
||||||
|
{
|
||||||
|
config(['app.env' => 'production']);
|
||||||
|
|
||||||
|
$this->get(route('laravel-websockets.dashboard'))
|
||||||
|
->assertResponseStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function can_see_dashboard()
|
||||||
|
{
|
||||||
|
$this->get(route('laravel-websockets.dashboard'))
|
||||||
|
->assertResponseOk()
|
||||||
|
->see('WebSockets Dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,10 +12,11 @@ use BeyondCode\LaravelWebSockets\Tests\Mocks\Message;
|
||||||
use BeyondCode\LaravelWebSockets\Tests\Statistics\Logger\FakeStatisticsLogger;
|
use BeyondCode\LaravelWebSockets\Tests\Statistics\Logger\FakeStatisticsLogger;
|
||||||
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
|
||||||
use GuzzleHttp\Psr7\Request;
|
use GuzzleHttp\Psr7\Request;
|
||||||
|
use Orchestra\Testbench\BrowserKit\TestCase as BaseTestCase;
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
use React\EventLoop\Factory as LoopFactory;
|
use React\EventLoop\Factory as LoopFactory;
|
||||||
|
|
||||||
abstract class TestCase extends \Orchestra\Testbench\TestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A test Pusher server.
|
* A test Pusher server.
|
||||||
|
|
@ -76,6 +77,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
*/
|
*/
|
||||||
protected function getEnvironmentSetUp($app)
|
protected function getEnvironmentSetUp($app)
|
||||||
{
|
{
|
||||||
|
$app['config']->set('app.key', 'wslxrEFGWY6GfGhvN9L3wH3KSRJQQpBD');
|
||||||
|
|
||||||
$app['config']->set('websockets.apps', [
|
$app['config']->set('websockets.apps', [
|
||||||
[
|
[
|
||||||
'name' => 'Test App',
|
'name' => 'Test App',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue