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

OutputTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 1
b 0
f 0
dl 0
loc 30
rs 10
1
<?php
2
3
namespace coreTests\Table;
4
5
6
use CommonTestClass;
7
use kalanis\kw_connect\arrays\Connector;
8
use kalanis\kw_connect\core\ConnectException;
9
use kalanis\kw_table\core\Table;
10
use kalanis\kw_table\core\Table\Columns;
11
use kalanis\kw_table\core\TableException;
12
13
14
class OutputTest extends CommonTestClass
15
{
16
    /**
17
     * @throws ConnectException
18
     * @throws TableException
19
     */
20
    public function testNormal(): void
21
    {
22
        $lib = new Table();
23
        $lib->addColumn('id', new Columns\Basic('id'));
24
25
        $lib->addDataSetConnector(new Connector($this->basicData()));
26
        $lib->setOutput(new XOutput($lib));
27
        $this->assertNotEmpty($lib->getOutput());
28
        $this->assertEquals('here will be table content', $lib->render());
29
    }
30
31
    /**
32
     * @throws ConnectException
33
     * @throws TableException
34
     */
35
    public function testNoOutput(): void
36
    {
37
        $lib = new Table(new Connector($this->basicData()));
38
        $lib->addColumn('id', new Columns\Basic('id'));
39
40
        $this->assertEmpty($lib->getOutput());
41
        $this->expectException(TableException::class);
42
        $this->expectExceptionMessage('Need to set output first!');
43
        $lib->render();
44
    }
45
46
    /**
47
     * @throws TableException
48
     */
49
    public function testNoDataset(): void
50
    {
51
        $lib = new Table();
52
        $lib->addColumn('id', new Columns\Basic('id'));
53
54
        $this->expectException(TableException::class);
55
        $this->expectExceptionMessage('Need to set dataset connector library first!');
56
        $lib->getDataSetConnector();
57
    }
58
}
59
60
61
class XOutput extends Table\AOutput
62
{
63
    public function render(): string
64
    {
65
        return 'here will be table content';
66
    }
67
}
68