| 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 |  |  |         $alternateCurrent = $this->pagination->paging(106, '/test-page', 3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->assertStringStartsWith("<ul", $alternateCurrent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->assertStringEndsWith("ul>", $alternateCurrent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $this->assertContains('<li class="active"><a href="/test-page?page=3" title="Page 3">3</a></li>', $pager); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->assertEquals('<ul class="pagination"><li><a href="/test-page?" title="Page «">«</a></li><li><a href="/test-page?page=2" title="Page <"><</a></li><li><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 class="active"><a href="/test-page?page=3" title="Page 3">3</a></li></ul>', $alternateCurrent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @covers Pager\Pagination::paging | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @covers Pager\Pagination::buildLink | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @covers Pager\Pagination::getPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @covers Pager\Pagination::buildQueryString | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @covers Pager\Pagination::getActiveClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @covers Pager\Pagination::getPaginationClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @covers Pager\Pagination::postLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @covers Pager\Pagination::preLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function testNoPagerNeeded(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->assertFalse($this->pagination->paging(10, '/test-page')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @covers Pager\Pagination::paging | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @covers Pager\Pagination::buildLink | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @covers Pager\Pagination::getPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @covers Pager\Pagination::buildQueryString | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  |      * @covers Pager\Pagination::getActiveClass | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |      * @covers Pager\Pagination::getPaginationClass | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |      * @covers Pager\Pagination::postLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @covers Pager\Pagination::preLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function testPagerArrows(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->markTestIncomplete('Test not yet implemented'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @covers Pager\Pagination::paging | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @covers Pager\Pagination::buildLink | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @covers Pager\Pagination::getPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @covers Pager\Pagination::buildQueryString | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @covers Pager\Pagination::getActiveClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * @covers Pager\Pagination::getPaginationClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @covers Pager\Pagination::postLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @covers Pager\Pagination::preLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     public function testPagerWithQueryString(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->markTestIncomplete('Test not yet implemented'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @covers Pager\Pagination::setPaginationClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @covers Pager\Pagination::getPaginationClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     public function testSetPagerClass(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $this->assertEquals('pagination', $this->pagination->getPaginationClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $this->pagination->setPaginationClass('my-class'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertNotEquals('pagination', $this->pagination->getPaginationClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->assertEquals('my-class', $this->pagination->getPaginationClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->pagination->setPaginationClass('paginationclass6'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $this->assertEquals('paginationclass6', $this->pagination->getPaginationClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * @covers Pager\Pagination::setActiveClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @covers Pager\Pagination::getActiveClass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public function testSetActiveClass(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->assertEquals('active', $this->pagination->getActiveClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->pagination->setActiveClass('current'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->assertNotEquals('active', $this->pagination->getActiveClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $this->assertEquals('current', $this->pagination->getActiveClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $this->pagination->setActiveClass('current active-class'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->assertEquals('current active-class', $this->pagination->getActiveClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 110 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 111 |  |  |  |