Passed
Push — master ( 62264f...226050 )
by Petr
08:16
created

MapColumnTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 12
c 0
b 0
f 0
dl 0
loc 40
rs 10
1
<?php
2
3
namespace coreTests\Columns;
4
5
6
use CommonTestClass;
7
use kalanis\kw_connect\arrays\Row;
8
use kalanis\kw_connect\core\ConnectException;
9
use kalanis\kw_table\core\Table\Columns;
10
11
12
class MapColumnTest extends CommonTestClass
13
{
14
    /**
15
     * @throws ConnectException
16
     */
17
    public function testMapTrans(): void
18
    {
19
        $lib = new Columns\Map('here', $this->mapTrans(), 'not here');
20
        $this->assertEquals('pasive', $lib->getValue($this->getRow()));
21
    }
22
23
    /**
24
     * @throws ConnectException
25
     */
26
    public function testMapNot(): void
27
    {
28
        $lib = new Columns\Map('far', $this->mapTrans(), 'not here');
29
        $this->assertEquals('not here', $lib->getValue($this->getRow()));
30
    }
31
32
    /**
33
     * @throws ConnectException
34
     */
35
    public function testMapWtf(): void
36
    {
37
        $lib = new Columns\Map('out', $this->mapTrans(), 'not here');
38
        $this->assertEquals('456', $lib->getValue($this->getRow()));
39
    }
40
41
    protected function getRow(): Row
42
    {
43
        return new Row(['id' => 2, 'here' => 1, 'far' => 0, 'out' => 456]);
44
    }
45
46
    protected function mapTrans(): array
47
    {
48
        return [
49
            1 => 'pasive',
50
            2 => 'active',
51
            3 => 'roar',
52
        ];
53
    }
54
}
55