1
0
Fork 0
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:
Robin Appelman 2017-03-21 21:24:18 +01:00
commit 9c963fd3af
7 changed files with 149 additions and 29 deletions

View 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]);
}
}

View 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() {
}
}