PgsqlStorageTest::testStoreMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace tests\codeception\unit;
3
4
use jones\wschat\components\AbstractStorage;
5
use yii\codeception\TestCase;
6
7
/**
8
 * Class PgsqlStorageTest
9
 * @package tests\codeception\unit
10
 */
11
class PgsqlStorageTest extends TestCase
12
{
13
    protected $params = [
14
        'chat_id' => 1,
15
        'chat_title' => 'Pgsql chat room',
16
        'user_id' => 1,
17
        'username' => 'Pgsql user',
18
        'avatar_16' => null,
19
        'avatar_32' => null,
20
        'message' => 'Simple text message',
21
        'timestamp' => 0
22
    ];
23
24
    /**
25
     * @covers \jones\wschat\components\DbStorage::storeMessage
26
     */
27
    public function testStoreMessage()
28
    {
29
        AbstractStorage::factory('pgsql')->storeMessage($this->params);
30
    }
31
32
    /**
33
     * @depends testStoreMessage
34
     * @covers \jones\wschat\components\DbStorage::getHistory
35
     */
36 View Code Duplication
    public function testGetHistory()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $data = AbstractStorage::factory('pgsql')->getHistory($this->params['chat_id']);
39
        $this->assertNotEmpty($data);
40
        $this->assertEquals(1, sizeof($data), 'Only one message should be in history table');
41
        $this->assertEquals($this->params['message'], $data[0]['message']);
42
    }
43
44
}
45