|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | +* Materialize Pagination Test |
| 5 | +*/ |
| 6 | +use Illuminate\Pagination\LengthAwarePaginator; |
| 7 | +use Landish\Pagination\Materialize as MaterializePresenter; |
| 8 | + |
| 9 | +class MaterializePaginationTest extends PHPUnit_Framework_TestCase |
| 10 | +{ |
| 11 | + protected $array = []; |
| 12 | + protected $dir; |
| 13 | + protected $presenter; |
| 14 | + |
| 15 | + public function __construct() { |
| 16 | + |
| 17 | + parent::__construct(); |
| 18 | + |
| 19 | + for ($i = 1; $i <= 13; $i++) { |
| 20 | + $this->array[$i] = 'item'.$i; |
| 21 | + } |
| 22 | + |
| 23 | + $this->dir = __DIR__.'/fixtures/materialize/'; |
| 24 | + } |
| 25 | + |
| 26 | + public function testMaterializePresenterCanGenerateLinksForSlider() |
| 27 | + { |
| 28 | + $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7); |
| 29 | + $presenter = new MaterializePresenter($p); |
| 30 | + |
| 31 | + $this->assertEquals( |
| 32 | + trim(file_get_contents($this->dir.'slider.html')), |
| 33 | + $presenter->render() |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + public function testMaterializePresenterCanGenerateLinksForTooCloseToBegining() |
| 38 | + { |
| 39 | + $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2); |
| 40 | + $presenter = new MaterializePresenter($p); |
| 41 | + |
| 42 | + $this->assertEquals( |
| 43 | + trim(file_get_contents($this->dir.'beginning.html')), |
| 44 | + $presenter->render() |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + public function testMaterializePresenterCanGenerateLinksForTooCloseToEnding() |
| 49 | + { |
| 50 | + $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12); |
| 51 | + $presenter = new MaterializePresenter($p); |
| 52 | + |
| 53 | + $this->assertEquals( |
| 54 | + trim(file_get_contents($this->dir.'ending.html')), |
| 55 | + $presenter->render() |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + public function testMaterializePresenterCanGenerateLinksForLastPage() |
| 60 | + { |
| 61 | + $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13); |
| 62 | + $presenter = new MaterializePresenter($p); |
| 63 | + |
| 64 | + $this->assertEquals( |
| 65 | + trim(file_get_contents($this->dir.'last_page.html')), |
| 66 | + $presenter->render() |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + public function testMaterializePresenterCanGenerateLinksForFirstPage() |
| 71 | + { |
| 72 | + $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1); |
| 73 | + $presenter = new MaterializePresenter($p); |
| 74 | + |
| 75 | + $this->assertEquals( |
| 76 | + trim(file_get_contents($this->dir.'first_page.html')), |
| 77 | + $presenter->render() |
| 78 | + ); |
| 79 | + } |
| 80 | +} |
0 commit comments