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

RowsTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 24
c 0
b 0
f 0
dl 0
loc 47
rs 10
1
<?php
2
3
namespace coreTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_connect\arrays\Row;
8
use kalanis\kw_table\core\Table\Columns\Basic;
9
use kalanis\kw_table\core\Table\Rows;
10
use kalanis\kw_table\core\Table\Internal;
11
12
13
class RowsTest extends CommonTestClass
14
{
15
    public function testRowStyled(): void
16
    {
17
        $lib = new Internal\Row();
18
        $this->assertEmpty($lib->getSource());
19
        $src = $this->getRow();
20
        $lib->setSource($src);
21
        $this->assertEquals($src, $lib->getSource());
22
        $lib->addColumn(new Basic('foo'));
23
    }
24
25
    public function testRowAb(): void
26
    {
27
        $lib = new XRow();
28
        $this->assertEmpty($lib->getFunctionName());
29
        $this->assertEmpty($lib->getFunctionArgs());
30
        $lib->setFunctionName('substr');
31
        $this->assertEquals('substr', $lib->getFunctionName());
32
        $lib->setFunctionArgs(['nop', 'ouf']);
33
        $this->assertEquals(['nop', 'ouf'], $lib->getFunctionArgs());
34
    }
35
36
    public function testRowFn(): void
37
    {
38
        $lib = new Rows\FunctionRow('substr', ['foo', 'bar']);
39
        $this->assertEquals('substr', $lib->getFunctionName());
40
        $this->assertEquals(['foo', 'bar'], $lib->getFunctionArgs());
41
    }
42
43
    public function testRowTbl(): void
44
    {
45
        $lib = new Rows\TableRow('substr', ['foo', 'bar']);
46
        $this->assertEquals('substr', $lib->getFunctionName());
47
        $this->assertEquals(['foo', 'bar'], $lib->getFunctionArgs());
48
    }
49
50
    public function testRowCl(): void
51
    {
52
        $lib = new Rows\ClassRow('preferred', 'some rule', 'where');
53
        $this->assertEquals('class', $lib->getFunctionName());
54
        $this->assertEquals(['preferred', 'some rule', 'where'], $lib->getFunctionArgs());
55
    }
56
57
    protected function getRow(): Row
58
    {
59
        return new Row(['id' => 2, 'name' => 'def', 'desc' => '<lang_to_"convert">', 'size' => 456, 'enabled' => 0]);
60
    }
61
}
62
63
64
class XRow extends Rows\ARow
65
{
66
}
67