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

43 lines
1.2 KiB
PHP
Raw Normal View History

2018-12-03 12:49:56 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\Tests\Statistics\Controllers;
2018-12-04 21:22:33 +00:00
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebSocketStatisticsEntriesController;
2020-03-04 09:58:39 +00:00
use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
use BeyondCode\LaravelWebSockets\Tests\TestCase;
2018-12-03 12:49:56 +00:00
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);
$actual = $entries->first()->attributesToArray();
foreach ($this->payload() as $key => $value) {
$this->assertArrayHasKey($key, $actual);
$this->assertSame($value, $actual[$key]);
}
2018-12-03 12:49:56 +00:00
}
protected function payload(): array
{
return [
'app_id' => config('websockets.apps.0.id'),
'peak_connection_count' => '1',
'websocket_message_count' => '2',
'api_message_count' => '3',
2018-12-03 12:49:56 +00:00
];
}
2018-12-04 21:22:33 +00:00
}