|
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 <[email protected]> |
|
10
|
|
|
// +---------------------------------------------------------------------- |
|
11
|
|
|
|
|
12
|
|
|
namespace tests\thinkphp\library\think; |
|
13
|
|
|
|
|
14
|
|
|
use think\paginator\driver\Bootstrap; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class paginateTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
public function testPaginatorInfo() |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
$p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 4); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertEquals(4, $p->total()); |
|
23
|
|
|
|
|
24
|
|
|
$this->assertEquals(2, $p->listRows()); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertEquals(2, $p->currentPage()); |
|
27
|
|
|
|
|
28
|
|
|
$p2 = Bootstrap::make($array2 = ['item3', 'item4'], 2, 2, 2); |
|
29
|
|
|
$this->assertEquals(1, $p2->currentPage()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testPaginatorRender() |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$p = Bootstrap::make($array = ['item3', 'item4'], 2, 2, 100); |
|
35
|
|
|
$render = '<ul class="pagination"><li><a href="/?page=1">«</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">»</a></li></ul>'; |
|
36
|
|
|
|
|
37
|
|
|
$this->assertEquals($render, $p->render()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|