|
4 | 4 |
|
5 | 5 | use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger;
|
6 | 6 | use BeyondCode\LaravelWebSockets\Statistics\Logger\RedisStatisticsLogger;
|
| 7 | +use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry; |
7 | 8 | use BeyondCode\LaravelWebSockets\Tests\TestCase;
|
8 | 9 |
|
9 | 10 | class RedisStatisticsLoggerTest extends TestCase
|
@@ -76,50 +77,26 @@ public function it_counts_connections_with_redis_logger_with_no_data()
|
76 | 77 | {
|
77 | 78 | config(['cache.default' => 'redis']);
|
78 | 79 |
|
79 |
| - $connection = $this->getConnectedWebSocketConnection(['channel-1']); |
80 |
| - |
81 | 80 | $logger = new RedisStatisticsLogger(
|
82 | 81 | $this->channelManager,
|
83 | 82 | $this->statisticsDriver
|
84 | 83 | );
|
85 | 84 |
|
| 85 | + $logger->resetAppTraces('1'); |
86 | 86 | $logger->resetAppTraces('1234');
|
87 | 87 |
|
88 |
| - $logger->webSocketMessage($connection->app->id); |
89 |
| - $logger->apiMessage($connection->app->id); |
90 |
| - $logger->connection($connection->app->id); |
91 |
| - $logger->disconnection($connection->app->id); |
92 |
| - |
93 |
| - $logger->save(); |
94 |
| - |
95 |
| - $this->markTestIncomplete( |
96 |
| - 'The numbers does not seem to match well.' |
97 |
| - ); |
98 |
| - } |
99 |
| - |
100 |
| - /** @test */ |
101 |
| - public function it_counts_connections_with_redis_logger_with_existing_data() |
102 |
| - { |
103 |
| - config(['cache.default' => 'redis']); |
104 |
| - |
105 | 88 | $connection = $this->getConnectedWebSocketConnection(['channel-1']);
|
106 | 89 |
|
107 |
| - $logger = new RedisStatisticsLogger( |
108 |
| - $this->channelManager, |
109 |
| - $this->statisticsDriver |
110 |
| - ); |
111 |
| - |
112 |
| - $logger->resetStatistics('1234', 0); |
113 |
| - |
114 |
| - $logger->webSocketMessage($connection->app->id); |
115 | 90 | $logger->apiMessage($connection->app->id);
|
116 |
| - $logger->connection($connection->app->id); |
117 |
| - $logger->disconnection($connection->app->id); |
118 | 91 |
|
119 | 92 | $logger->save();
|
120 | 93 |
|
121 |
| - $this->markTestIncomplete( |
122 |
| - 'The numbers does not seem to match well.' |
123 |
| - ); |
| 94 | + $this->assertCount(1, WebSocketsStatisticsEntry::all()); |
| 95 | + |
| 96 | + $entry = WebSocketsStatisticsEntry::first(); |
| 97 | + |
| 98 | + $this->assertEquals(1, $entry->peak_connection_count); |
| 99 | + $this->assertEquals(1, $entry->websocket_message_count); |
| 100 | + $this->assertEquals(1, $entry->api_message_count); |
124 | 101 | }
|
125 | 102 | }
|
0 commit comments