1
|
|
|
<?php |
2
|
|
|
namespace Pager\Tests; |
3
|
|
|
|
4
|
|
|
use Pager\Pagination; |
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
|
7
|
|
|
class PaginationTest extends TestCase{ |
8
|
|
|
|
9
|
|
|
protected $pagination; |
10
|
|
|
|
11
|
|
|
public function setUp() { |
12
|
|
|
$this->pagination = new Pagination(); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
public function tearDown(){ |
16
|
|
|
unset($this->pagination); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @covers Pager\Pagination::paging |
21
|
|
|
* @covers Pager\Pagination::buildLink |
22
|
|
|
* @covers Pager\Pagination::getPage |
23
|
|
|
* @covers Pager\Pagination::buildQueryString |
24
|
|
|
* @covers Pager\Pagination::getActiveClass |
25
|
|
|
* @covers Pager\Pagination::getPaginationClass |
26
|
|
|
* @covers Pager\Pagination::postLinks |
27
|
|
|
* @covers Pager\Pagination::preLinks |
28
|
|
|
*/ |
29
|
|
|
public function testCreatePager(){ |
30
|
|
|
$pager = $this->pagination->paging(106, '/test-page'); |
31
|
|
|
$this->assertStringStartsWith("<ul", $pager); |
32
|
|
|
$this->assertStringEndsWith("ul>", $pager); |
33
|
|
|
$this->assertContains('<li class="active"><a href="/test-page?page=1" title="Page 1">1</a></li>', $pager); |
34
|
|
|
$this->assertEquals('<ul class="pagination"><li class="active"><a href="/test-page?page=1" title="Page 1">1</a></li><li><a href="/test-page?page=2" title="Page 2">2</a></li><li><a href="/test-page?page=3" title="Page 3">3</a></li><li><a href="/test-page?page=2" title="Page >">></a></li><li><a href="/test-page?page=3" title="Page »">»</a></li></ul>', $pager); |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @covers Pager\Pagination::paging |
41
|
|
|
* @covers Pager\Pagination::buildLink |
42
|
|
|
* @covers Pager\Pagination::getPage |
43
|
|
|
* @covers Pager\Pagination::buildQueryString |
44
|
|
|
* @covers Pager\Pagination::getActiveClass |
45
|
|
|
* @covers Pager\Pagination::getPaginationClass |
46
|
|
|
* @covers Pager\Pagination::postLinks |
47
|
|
|
* @covers Pager\Pagination::preLinks |
48
|
|
|
*/ |
49
|
|
|
public function testNoPagerNeeded(){ |
50
|
|
|
$this->assertFalse($this->pagination->paging(10, '/test-page')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @covers Pager\Pagination::paging |
55
|
|
|
* @covers Pager\Pagination::buildLink |
56
|
|
|
* @covers Pager\Pagination::getPage |
57
|
|
|
* @covers Pager\Pagination::buildQueryString |
58
|
|
|
* @covers Pager\Pagination::getActiveClass |
59
|
|
|
* @covers Pager\Pagination::getPaginationClass |
60
|
|
|
* @covers Pager\Pagination::postLinks |
61
|
|
|
* @covers Pager\Pagination::preLinks |
62
|
|
|
*/ |
63
|
|
|
public function testPagerArrows(){ |
64
|
|
|
$this->markTestIncomplete('Test not yet implemented'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @covers Pager\Pagination::paging |
69
|
|
|
* @covers Pager\Pagination::buildLink |
70
|
|
|
* @covers Pager\Pagination::getPage |
71
|
|
|
* @covers Pager\Pagination::buildQueryString |
72
|
|
|
* @covers Pager\Pagination::getActiveClass |
73
|
|
|
* @covers Pager\Pagination::getPaginationClass |
74
|
|
|
* @covers Pager\Pagination::postLinks |
75
|
|
|
* @covers Pager\Pagination::preLinks |
76
|
|
|
*/ |
77
|
|
|
public function testPagerWithQueryString(){ |
78
|
|
|
$this->markTestIncomplete('Test not yet implemented'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @covers Pager\Pagination::setPaginationClass |
83
|
|
|
* @covers Pager\Pagination::getPaginationClass |
84
|
|
|
*/ |
85
|
|
|
public function testSetPagerClass(){ |
86
|
|
|
$this->assertEquals('pagination', $this->pagination->getPaginationClass()); |
87
|
|
|
$this->pagination->setPaginationClass('my-class'); |
88
|
|
|
$this->assertNotEquals('pagination', $this->pagination->getPaginationClass()); |
89
|
|
|
$this->assertEquals('my-class', $this->pagination->getPaginationClass()); |
90
|
|
|
$this->pagination->setPaginationClass('paginationclass6'); |
91
|
|
|
$this->assertEquals('paginationclass6', $this->pagination->getPaginationClass()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @covers Pager\Pagination::setActiveClass |
96
|
|
|
* @covers Pager\Pagination::getActiveClass |
97
|
|
|
*/ |
98
|
|
|
public function testSetActiveClass(){ |
99
|
|
|
$this->assertEquals('active', $this->pagination->getActiveClass()); |
100
|
|
|
$this->pagination->setActiveClass('current'); |
101
|
|
|
$this->assertNotEquals('active', $this->pagination->getActiveClass()); |
102
|
|
|
$this->assertEquals('current', $this->pagination->getActiveClass()); |
103
|
|
|
$this->pagination->setActiveClass('current active-class'); |
104
|
|
|
$this->assertEquals('current active-class', $this->pagination->getActiveClass()); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|