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

37 lines
1.1 KiB
PHP
Raw Normal View History

2018-12-03 12:49:56 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\Tests\Statistics\Controllers;
2018-12-03 22:19:46 +00:00
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebSocketStatisticsEntriesController;
2018-12-03 12:49:56 +00:00
use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
use BeyondCode\LaravelWebSockets\Tests\TestCase;
class WebSocketsStatisticsControllerTest extends TestCase
{
/** @test */
public function it_can_store_statistics()
{
$this->post(
2018-12-03 22:19:46 +00:00
action([WebSocketStatisticsEntriesController::class, 'store']),
2018-12-04 09:25:34 +00:00
array_merge($this->payload(), [
'secret' => config('websockets.apps.0.secret'),
])
2018-12-03 12:49:56 +00:00
);
$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,
];
}
}