laravel-websockets/tests/Statistics/Controllers/WebSocketsStatisticsControl...

35 lines
1.0 KiB
PHP
Raw Normal View History

2018-12-03 12:49:56 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\Tests\Statistics\Controllers;
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebsocketStatisticsEntriesController;
use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
use BeyondCode\LaravelWebSockets\Tests\TestCase;
class WebSocketsStatisticsControllerTest extends TestCase
{
/** @test */
public function it_can_store_statistics()
{
$this->post(
action([WebsocketStatisticsEntriesController::class, 'store']),
$this->payload()
);
$entries = WebSocketsStatisticsEntry::get();
$this->assertCount(1, $entries);
$this->assertArraySubset($this->payload(), $entries->first()->attributesToArray());
}
protected function payload(): array
{
return [
'app_id' => config('websockets.apps.0.id'),
2018-12-03 13:35:00 +00:00
'peak_connection_count' => 1,
2018-12-03 12:49:56 +00:00
'websocket_message_count' => 2,
'api_message_count' => 3,
];
}
}