Passed
Push — master ( 9dbeef...fdd166 )
by Petr
07:45
created

CliPagerTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 8
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_paging\Render;
8
9
10
class CliPagerTest extends CommonTestClass
11
{
12
    public function testInstance(): void
13
    {
14
        $position = $this->getPositions();
15
        $position->getPager()->setActualPage(4);
16
        $pager = new Render\CliPager($position);
17
        $this->assertInstanceOf('\kalanis\kw_pager\Interfaces\IPager', $pager->getPager());
18
    }
19
20
    public function testMiddle(): void
21
    {
22
        $position = $this->getPositions();
23
        $position->getPager()->setActualPage(4);
24
        $pager = new Render\CliPager($position);
25
        $this->assertEquals($this->middle(), strval($pager));
26
    }
27
28
    protected function middle(): string
29
    {
30
        return '<< 1 | < 3 | 4 | 5 > | 7 >>' . PHP_EOL . 'Showing results 37 - 48 of total 75';
31
    }
32
33
    public function testStart(): void
34
    {
35
        $position = $this->getPositions();
36
        $position->getPager()->setActualPage($position->getFirstPage());
37
        $pager = new Render\CliPager($position);
38
        $this->assertEquals($this->start(), strval($pager));
39
    }
40
41
    protected function start(): string
42
    {
43
        return '-- | - | 1 | 2 > | 7 >>' . PHP_EOL . 'Showing results 1 - 12 of total 75';
44
    }
45
46
    public function testEnd(): void
47
    {
48
        $position = $this->getPositions();
49
        $position->getPager()->setActualPage($position->getLastPage());
50
        $pager = new Render\CliPager($position);
51
        $this->assertEquals($this->end(), strval($pager));
52
    }
53
54
    protected function end(): string
55
    {
56
        return '<< 1 | < 6 | 7 | - | --' . PHP_EOL . 'Showing results 73 - 75 of total 75';
57
    }
58
59
    public function testNothing(): void
60
    {
61
        $position = $this->getPositions();
62
        $position->getPager()->setMaxResults(10)->setActualPage($position->getFirstPage());
63
        $pager = new Render\CliPager($position);
64
        $this->assertEmpty(strval($pager));
65
    }
66
}
67