|
| 1 | +<?php |
| 2 | +require_once dirname(__DIR__).'/SimplePagination.php'; |
| 3 | + |
| 4 | +class SimplePaginationTest extends PHPUnit_Framework_TestCase |
| 5 | +{ |
| 6 | + public function test_construct() |
| 7 | + { |
| 8 | + $pagination = new SimplePagination(1, 10); |
| 9 | + $this->assertEquals(1, $pagination->current); |
| 10 | + $this->assertEquals(0, $pagination->prev); |
| 11 | + $this->assertEquals(2, $pagination->next); |
| 12 | + $this->assertEquals(10, $pagination->count); |
| 13 | + $this->assertEquals(1, $pagination->start_index); |
| 14 | + |
| 15 | + $pagination = new SimplePagination(2, 10); |
| 16 | + $this->assertEquals(2, $pagination->current); |
| 17 | + $this->assertEquals(1, $pagination->prev); |
| 18 | + $this->assertEquals(3, $pagination->next); |
| 19 | + $this->assertEquals(10, $pagination->count); |
| 20 | + $this->assertEquals(11, $pagination->start_index); |
| 21 | + } |
| 22 | + |
| 23 | + public function test_checkLastPage() |
| 24 | + { |
| 25 | + $items = array('a', 'b', 'c', 'd'); |
| 26 | + $pagination = new SimplePagination(1, 3); |
| 27 | + $pagination->checkLastPage($items); |
| 28 | + $this->assertFalse($pagination->is_last_page); |
| 29 | + |
| 30 | + $items = array('e', 'f', 'g'); |
| 31 | + $pagination = new SimplePagination(2, 3); |
| 32 | + $pagination->checkLastPage($items); |
| 33 | + $this->assertTrue($pagination->is_last_page); |
| 34 | + } |
| 35 | +} |
0 commit comments