Testing
This commit is contained in:
parent
9a0d56d6d3
commit
c7aea38cdc
|
|
@ -117,6 +117,18 @@ class PresenceChannelTest extends TestCase
|
||||||
$this->channelManager->getChannelMembers('1234', 'presence-channel')->then(function ($members) {
|
$this->channelManager->getChannelMembers('1234', 'presence-channel')->then(function ($members) {
|
||||||
$this->assertCount(2, $members);
|
$this->assertCount(2, $members);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->pusherServer->onClose($rick);
|
||||||
|
$this->pusherServer->onClose($morty);
|
||||||
|
$this->pusherServer->onClose($pickleRick);
|
||||||
|
|
||||||
|
$this->channelManager->getGlobalConnectionsCount('1234', 'presence-channel')->then(function ($total) {
|
||||||
|
$this->assertEquals(3, $total);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->channelManager->getChannelMembers('1234', 'presence-channel')->then(function ($members) {
|
||||||
|
$this->assertCount(2, $members);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_presence_channel_broadcast_member_events()
|
public function test_presence_channel_broadcast_member_events()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,23 @@ class StatisticsStoreTest extends TestCase
|
||||||
$this->assertEquals('2', $records[0]['peak_connections_count']);
|
$this->assertEquals('2', $records[0]['peak_connections_count']);
|
||||||
$this->assertEquals('2', $records[0]['websocket_messages_count']);
|
$this->assertEquals('2', $records[0]['websocket_messages_count']);
|
||||||
$this->assertEquals('0', $records[0]['api_messages_count']);
|
$this->assertEquals('0', $records[0]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->pusherServer->onClose($rick);
|
||||||
|
$this->pusherServer->onClose($morty);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
|
|
||||||
|
$this->assertEquals('2', $records[1]['peak_connections_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['websocket_messages_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
// The last one should not generate any more records
|
||||||
|
// since the current state is empty.
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_store_statistics_on_private_channel()
|
public function test_store_statistics_on_private_channel()
|
||||||
|
|
@ -30,19 +47,55 @@ class StatisticsStoreTest extends TestCase
|
||||||
$this->assertEquals('2', $records[0]['peak_connections_count']);
|
$this->assertEquals('2', $records[0]['peak_connections_count']);
|
||||||
$this->assertEquals('2', $records[0]['websocket_messages_count']);
|
$this->assertEquals('2', $records[0]['websocket_messages_count']);
|
||||||
$this->assertEquals('0', $records[0]['api_messages_count']);
|
$this->assertEquals('0', $records[0]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->pusherServer->onClose($rick);
|
||||||
|
$this->pusherServer->onClose($morty);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
|
|
||||||
|
$this->assertEquals('2', $records[1]['peak_connections_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['websocket_messages_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
// The last one should not generate any more records
|
||||||
|
// since the current state is empty.
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_store_statistics_on_presence_channel()
|
public function test_store_statistics_on_presence_channel()
|
||||||
{
|
{
|
||||||
$rick = $this->newPresenceConnection('presence-channel', ['user_id' => 1]);
|
$rick = $this->newPresenceConnection('presence-channel', ['user_id' => 1]);
|
||||||
$morty = $this->newPresenceConnection('presence-channel', ['user_id' => 2]);
|
$morty = $this->newPresenceConnection('presence-channel', ['user_id' => 2]);
|
||||||
|
$pickleRick = $this->newPresenceConnection('presence-channel', ['user_id' => 1]);
|
||||||
|
|
||||||
$this->statisticsCollector->save();
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
$this->assertCount(1, $records = $this->statisticsStore->getRecords());
|
$this->assertCount(1, $records = $this->statisticsStore->getRecords());
|
||||||
|
|
||||||
$this->assertEquals('2', $records[0]['peak_connections_count']);
|
$this->assertEquals('3', $records[0]['peak_connections_count']);
|
||||||
$this->assertEquals('2', $records[0]['websocket_messages_count']);
|
$this->assertEquals('3', $records[0]['websocket_messages_count']);
|
||||||
$this->assertEquals('0', $records[0]['api_messages_count']);
|
$this->assertEquals('0', $records[0]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->pusherServer->onClose($rick);
|
||||||
|
$this->pusherServer->onClose($morty);
|
||||||
|
$this->pusherServer->onClose($pickleRick);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
|
|
||||||
|
$this->assertEquals('3', $records[1]['peak_connections_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['websocket_messages_count']);
|
||||||
|
$this->assertEquals('0', $records[1]['api_messages_count']);
|
||||||
|
|
||||||
|
$this->statisticsCollector->save();
|
||||||
|
|
||||||
|
// The last one should not generate any more records
|
||||||
|
// since the current state is empty.
|
||||||
|
$this->assertCount(2, $records = $this->statisticsStore->getRecords());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue