mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
extract chat handling
This commit is contained in:
parent
66d177e23a
commit
9c963fd3af
7 changed files with 149 additions and 29 deletions
37
tests/Providers/ChatProviderTest.php
Normal file
37
tests/Providers/ChatProviderTest.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php namespace Demostf\API\Test\Providers;
|
||||
|
||||
use Demostf\API\Demo\ChatMessage;
|
||||
use Demostf\API\Providers\ChatProvider;
|
||||
use Demostf\API\Test\TestCase;
|
||||
|
||||
class ChatProviderTest extends TestCase {
|
||||
/** @var ChatProvider */
|
||||
private $provider;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->provider = new ChatProvider($this->getDatabaseConnection());
|
||||
}
|
||||
|
||||
public function testGetEmptyChat() {
|
||||
$this->assertCount(0, $this->provider->getChat(1));
|
||||
}
|
||||
|
||||
public function testStoreRetrieve() {
|
||||
$message1 = new ChatMessage('foo', 2, 'bar');
|
||||
$message2 = new ChatMessage('foo2', 2, 'bar2');
|
||||
$message3 = new ChatMessage('foo2', 2, 'bar2');
|
||||
|
||||
$this->provider->storeChatMessage(1, $message1);
|
||||
$this->provider->storeChatMessage(1, $message2);
|
||||
$this->provider->storeChatMessage(2, $message3);
|
||||
|
||||
$result = $this->provider->getChat(1);
|
||||
sort($result);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertEquals($message1, $result[0]);
|
||||
$this->assertEquals($message2, $result[1]);
|
||||
}
|
||||
}
|
||||
18
tests/Providers/InfoProviderTest.php
Normal file
18
tests/Providers/InfoProviderTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php namespace Demostf\API\Test\Providers;
|
||||
|
||||
use Demostf\API\Providers\InfoProvider;
|
||||
use Demostf\API\Test\TestCase;
|
||||
|
||||
class InfoProviderTest extends TestCase {
|
||||
/** @var InfoProvider */
|
||||
private $provider;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->provider = new InfoProvider($this->getDatabaseConnection());
|
||||
}
|
||||
|
||||
public function testGetStats() {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue