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

35 lines
1022 B
PHP

<?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'),
'peak_connections' => 1,
'websocket_message_count' => 2,
'api_message_count' => 3,
];
}
}