Added --test for websockets:serve command
This commit is contained in:
parent
815eabc801
commit
344dfa7f96
|
|
@ -23,7 +23,12 @@ use React\Socket\Connector;
|
||||||
|
|
||||||
class StartWebSocketServer extends Command
|
class StartWebSocketServer extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'websockets:serve {--host=0.0.0.0} {--port=6001} {--debug : Forces the loggers to be enabled and thereby overriding the app.debug config setting } ';
|
protected $signature = 'websockets:serve
|
||||||
|
{--host=0.0.0.0}
|
||||||
|
{--port=6001}
|
||||||
|
{--debug : Forces the loggers to be enabled and thereby overriding the APP_DEBUG setting.}
|
||||||
|
{--test : Prepare the server, but do not start it.}
|
||||||
|
';
|
||||||
|
|
||||||
protected $description = 'Start the Laravel WebSocket Server';
|
protected $description = 'Start the Laravel WebSocket Server';
|
||||||
|
|
||||||
|
|
@ -142,15 +147,18 @@ class StartWebSocketServer extends Command
|
||||||
|
|
||||||
$routes = WebSocketsRouter::getRoutes();
|
$routes = WebSocketsRouter::getRoutes();
|
||||||
|
|
||||||
/* 🛰 Start the server 🛰 */
|
$server = (new WebSocketServerFactory())
|
||||||
(new WebSocketServerFactory())
|
|
||||||
->setLoop($this->loop)
|
->setLoop($this->loop)
|
||||||
->useRoutes($routes)
|
->useRoutes($routes)
|
||||||
->setHost($this->option('host'))
|
->setHost($this->option('host'))
|
||||||
->setPort($this->option('port'))
|
->setPort($this->option('port'))
|
||||||
->setConsoleOutput($this->output)
|
->setConsoleOutput($this->output)
|
||||||
->createServer()
|
->createServer();
|
||||||
->run();
|
|
||||||
|
if (! $this->option('test')) {
|
||||||
|
/* 🛰 Start the server 🛰 */
|
||||||
|
$server->run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configurePubSubReplication()
|
protected function configurePubSubReplication()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeyondCode\LaravelWebSockets\Tests\Commands;
|
||||||
|
|
||||||
|
use Artisan;
|
||||||
|
use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
|
||||||
|
use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class StartWebSocketServerTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @test */
|
||||||
|
public function does_not_fail_if_building_up()
|
||||||
|
{
|
||||||
|
$this->artisan('websockets:serve', ['--test' => true]);
|
||||||
|
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue