Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from arandilopez/master
Browse files Browse the repository at this point in the history
Pagination for MaterializeCSS
  • Loading branch information
liorocks committed May 25, 2015
2 parents be7022b + f4b9b6d commit 4607dc1
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Materialize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php namespace Landish\Pagination;


class Materialize extends Pagination {

/**
* Available page wrapper HTML.
*
* @var string
*/
protected $availablePageWrapper = '<li class="waves-effect"><a href="%s">%s</a></li>';

/**
* Get active page wrapper HTML.
*
* @var string
*/
protected $activePageWrapper = '<li class="active"><a href="#!">%s</a></li>';

/**
* Get disabled page wrapper HTML.
*
* @var string
*/
protected $disabledPageWrapper = '<li class="disabled"><a href="#!">%s</a></li>';

/**
* Previous button text.
*
* @var string
*/
protected $previousButtonText = '<i class="mdi-navigation-chevron-left"></i>';

/**
* Next button text.
*
* @var string
*/
protected $nextButtonText = '<i class="mdi-navigation-chevron-right"></i>';

}
80 changes: 80 additions & 0 deletions tests/MaterializePaginationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

/**
* Materialize Pagination Test
*/
use Illuminate\Pagination\LengthAwarePaginator;
use Landish\Pagination\Materialize as MaterializePresenter;

class MaterializePaginationTest extends PHPUnit_Framework_TestCase
{
protected $array = [];
protected $dir;
protected $presenter;

public function __construct() {

parent::__construct();

for ($i = 1; $i <= 13; $i++) {
$this->array[$i] = 'item'.$i;
}

$this->dir = __DIR__.'/fixtures/materialize/';
}

public function testMaterializePresenterCanGenerateLinksForSlider()
{
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
$presenter = new MaterializePresenter($p);

$this->assertEquals(
trim(file_get_contents($this->dir.'slider.html')),
$presenter->render()
);
}

public function testMaterializePresenterCanGenerateLinksForTooCloseToBegining()
{
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
$presenter = new MaterializePresenter($p);

$this->assertEquals(
trim(file_get_contents($this->dir.'beginning.html')),
$presenter->render()
);
}

public function testMaterializePresenterCanGenerateLinksForTooCloseToEnding()
{
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
$presenter = new MaterializePresenter($p);

$this->assertEquals(
trim(file_get_contents($this->dir.'ending.html')),
$presenter->render()
);
}

public function testMaterializePresenterCanGenerateLinksForLastPage()
{
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
$presenter = new MaterializePresenter($p);

$this->assertEquals(
trim(file_get_contents($this->dir.'last_page.html')),
$presenter->render()
);
}

public function testMaterializePresenterCanGenerateLinksForFirstPage()
{
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
$presenter = new MaterializePresenter($p);

$this->assertEquals(
trim(file_get_contents($this->dir.'first_page.html')),
$presenter->render()
);
}
}
1 change: 1 addition & 0 deletions tests/fixtures/materialize/beginning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ul class="pagination"><li class="waves-effect"><a href="/?page=1"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="active"><a href="#!">2</a></li><li class="waves-effect"><a href="/?page=3">3</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=3"><i class="mdi-navigation-chevron-right"></i></a></li></ul>
1 change: 1 addition & 0 deletions tests/fixtures/materialize/ending.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ul class="pagination"><li class="waves-effect"><a href="/?page=11"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="waves-effect"><a href="/?page=11">11</a></li><li class="active"><a href="#!">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=13"><i class="mdi-navigation-chevron-right"></i></a></li></ul>
1 change: 1 addition & 0 deletions tests/fixtures/materialize/first_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ul class="pagination"><li class="disabled"><a href="#!"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="active"><a href="#!">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="waves-effect"><a href="/?page=3">3</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=2"><i class="mdi-navigation-chevron-right"></i></a></li></ul>
1 change: 1 addition & 0 deletions tests/fixtures/materialize/last_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ul class="pagination"><li class="waves-effect"><a href="/?page=12"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="waves-effect"><a href="/?page=11">11</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="active"><a href="#!">13</a></li> <li class="disabled"><a href="#!"><i class="mdi-navigation-chevron-right"></i></a></li></ul>
1 change: 1 addition & 0 deletions tests/fixtures/materialize/slider.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ul class="pagination"><li class="waves-effect"><a href="/?page=6"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="active"><a href="#!">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=8"><i class="mdi-navigation-chevron-right"></i></a></li></ul>

0 comments on commit 4607dc1

Please sign in to comment.