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