paginateTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace tests\thinkphp\library\think;
  12. use think\paginator\driver\Bootstrap;
  13. class paginateTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testPaginatorInfo()
  16. {
  17. $p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 4);
  18. $this->assertEquals(4, $p->total());
  19. $this->assertEquals(2, $p->listRows());
  20. $this->assertEquals(2, $p->currentPage());
  21. $p2 = Bootstrap::make($array2 = ['item3', 'item4'], 2, 2, 2);
  22. $this->assertEquals(1, $p2->currentPage());
  23. }
  24. public function testPaginatorRender()
  25. {
  26. $p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 100);
  27. $render = '<ul class="pagination"><li><a href="/?page=1">&laquo;</a></li> <li><a href="/?page=1">1</a></li><li class="active"><span>2</span></li><li><a href="/?page=3">3</a></li><li><a href="/?page=4">4</a></li><li><a href="/?page=5">5</a></li><li><a href="/?page=6">6</a></li><li><a href="/?page=7">7</a></li><li><a href="/?page=8">8</a></li><li class="disabled"><span>...</span></li><li><a href="/?page=49">49</a></li><li><a href="/?page=50">50</a></li> <li><a href="/?page=3">&raquo;</a></li></ul>';
  28. $this->assertEquals($render, $p->render());
  29. }
  30. }