├── .gitignore
├── .travis.yml
├── README.md
├── composer.json
├── phpunit.xml.dist
├── src
├── Materialize.php
├── Pagination.php
├── PaginationHTML.php
├── SemanticUI.php
├── Simple
│ ├── Materialize.php
│ ├── Pagination.php
│ ├── SemanticUI.php
│ ├── UIKit.php
│ └── ZurbFoundation.php
├── UIKit.php
└── ZurbFoundation.php
└── tests
├── BootstrapPaginationTest.php
├── MaterializePaginationTest.php
├── SemanticUIPaginatonTest.php
├── UIKitPaginationTest.php
├── ZurbFoundationPaginationTest.php
└── fixtures
├── bootstrap
├── beginning.html
├── ending.html
├── first_page.html
├── last_page.html
└── slider.html
├── foundation
├── beginning.html
├── ending.html
├── first_page.html
├── last_page.html
└── slider.html
├── materialize
├── beginning.html
├── ending.html
├── first_page.html
├── last_page.html
└── slider.html
├── semantic
├── beginning.html
├── ending.html
├── first_page.html
├── last_page.html
└── slider.html
└── uikit
├── beginning.html
├── ending.html
├── first_page.html
├── last_page.html
└── slider.html
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | /vendor
3 | .DS_Store
4 | composer.lock
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.6
5 |
6 | branches:
7 |
8 | before_script:
9 | - composer install
10 |
11 | script: phpunit
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Landish/Pagination
2 |
3 | > Note: Works with only **5.0**, **5.1** and **5.2** versions. **5.3** and above it does **not** work. PR's welcome!
4 |
5 | [](https://travis-ci.org/Landish/Pagination)
6 | [](https://packagist.org/packages/landish/pagination)
7 | [](https://packagist.org/packages/landish/pagination)
8 | [](https://packagist.org/packages/landish/pagination)
9 | [](https://packagist.org/packages/landish/pagination)
10 |
11 | [Laravel 5](http://laravel.com/) comes with [Pagination](http://laravel.com/docs/pagination) class, which is perfectly rendered to match [Bootstrap 3](http://getbootstrap.com/components/#pagination) styles.
12 |
13 | This package gives you ability to change the display output of rendered pagination elements for Front-end Frameworks, such as: [Semantic UI](http://semantic-ui.com/collections/menu.html#pagination), [Zurb Foundation](http://foundation.zurb.com/docs/components/pagination.html), [UIKit](http://getuikit.com/docs/pagination.html) and [Materialize](http://materializecss.com/).
14 |
15 | With this package it is also very easy to [create custom pagination](#create-custom-pagination) HTML output.
16 |
17 | ## Table of Contents
18 | * [Installation](#installation)
19 | * [Usage](#usage)
20 | * [Usage - Recommended Way](#usage---recommended-way)
21 | * [Simple Pagination](#simple-pagination)
22 | * [Additional Wrappers](#additional-wrappers)
23 | * [Appending To Pagination Links](#appending-to-pagination-links)
24 | * [Create Custom Pagination](#create-custom-pagination)
25 | * [License](#license)
26 |
27 |
28 | ## Installation
29 |
30 | To install `landish/pagination` package, you have to run the following command in your Terminal, or Comand Promt:
31 |
32 | ```
33 | $ composer require landish/pagination
34 | ```
35 |
36 | Or manually add the following lines in to your `composer.json` file:
37 |
38 | ```json
39 | "require": {
40 | "landish/pagination": "~1.0"
41 | }
42 | ```
43 |
44 | and run the `composer update` or `composer install` command.
45 |
46 | ## Usage
47 |
48 | Add following lines of code in your `*.blade.php` file, where you want to dispay the pagination.
49 |
50 | For [Semantic UI](http://semantic-ui.com/):
51 |
52 | ```php
53 | {!! (new Landish\Pagination\SemanticUI($items))->render() !!}
54 | // or add "\Simple" in namespace for "Simple Pagination"
55 | {!! (new Landish\Pagination\Simple\SemanticUI($items))->render() !!}
56 | ```
57 |
58 | For [Zurb Foundation](http://foundation.zurb.com/):
59 |
60 | ```php
61 | {!! (new Landish\Pagination\ZurbFoundation($items))->render() !!}
62 | // or add "\Simple" in namespace for "Simple Pagination"
63 | {!! (new Landish\Pagination\Simple\ZurbFoundation($items))->render() !!}
64 | ```
65 |
66 | For [UIKit](http://getuikit.com/):
67 |
68 | ```php
69 | {!! (new Landish\Pagination\UIKit($items))->render() !!}
70 | // or add "\Simple" in namespace for "Simple Pagination"
71 | {!! (new Landish\Pagination\Simple\UIKit($items))->render() !!}
72 | ```
73 |
74 | For [Materialize](http://materializecss.com/) (Contributed by [@arandilopez](https://github.com/arandilopez)):
75 |
76 | ```php
77 | {!! (new Landish\Pagination\Materialize($items))->render() !!}
78 | // or add "\Simple" in namespace for "Simple Pagination"
79 | {!! (new Landish\Pagination\Simple\Materialize($items))->render() !!}
80 | ```
81 |
82 | ## Usage - Recommended Way
83 |
84 | If you display pagination on several pages of your web application and have to write to the output code in several files, then this is, what I would recommend to do:
85 |
86 | Just create `Pagination.php` file in your `/app/` directory and paste the following code:
87 |
88 | > **Note:** This example is suitable for you, if you haven't change the [Laravel Application Namespace](http://laravel.com/docs/5.0/structure#namespacing-your-application), otherwise just use your custom namespace instead of `App`.
89 |
90 | ```php
91 | render() !!}
107 | ```
108 |
109 | And in future, if you decide to override the output of pagination elements, it will be much more easier to change in `app/Pagination.php` file, rather then in several blade template files.
110 |
111 | ## Simple Pagination
112 |
113 | [Laravel](http://laravel.com/docs/5.0/pagination) gives you ability to create "Simple Pagination", which will have only `Previous` and `Next` buttons, something like [Bootstrap](http://getbootstrap.com/components/#pagination-pager) has.
114 |
115 | The `landish/pagination` package supports this kind of pagination for [Semantic UI](http://semantic-ui.com/collections/menu.html#pagination), [Zurb Foundation](http://foundation.zurb.com/docs/components/pagination.html) and [UIKit](http://getuikit.com/docs/pagination.html).
116 |
117 | In order to use, first call the [`simplePaginate()`](http://laravel.com/api/5.0/Illuminate/Database/Eloquent/Builder.html#method_simplePaginate) method on Eloquent Model.
118 |
119 | ```php
120 | $items = User::where('votes', '>', 100)->simplePaginate(15);
121 | ```
122 |
123 | And after that, add the `\Simple` suffix in namespace, when displaying the pagination output. Something like this:
124 |
125 | ```php
126 | {!! (new Landish\Pagination\Simple\ZurbFoundation($items))->render() !!}
127 | ```
128 |
129 | ## Additional Wrappers
130 |
131 | If you need to add additional wrappers to your pagination output, which will be displayed only if items have pages, then you can do it like this:
132 |
133 | ```php
134 | @if($items->hasPages())
135 |
140 | @endif
141 | ```
142 |
143 | Of course, you are free to change the `.pagination-wrapper` and `.pagination-wrapper-inner` CSS classes and the HTML.
144 |
145 | ## Appending To Pagination Links
146 |
147 | [Appending to pagination links](http://laravel.com/docs/5.0/pagination#appending-to-pagination-links) gives you ability to add extra query strings to your pagination links.
148 |
149 | With this package you can do it with following lines of code:
150 |
151 | ```php
152 | {!! $items->appends(['key' => 'value'])->render(new App\Pagination($items)) !!}
153 | ```
154 |
155 | ## Create Custom Pagination
156 |
157 | Creating custom pagination or extending `landish/pagination` package is very easy.
158 |
159 | [`Landish\Pagination\PaginationHTML`](https://github.com/Landish/Pagination/blob/master/src/PaginationHTML.php) class contains the following properties:
160 |
161 | ```php
162 | %s %s %s';
172 |
173 | /**
174 | * Available page wrapper HTML.
175 | *
176 | * @var string
177 | */
178 | protected $availablePageWrapper = '%s';
179 |
180 | /**
181 | * Get active page wrapper HTML.
182 | *
183 | * @var string
184 | */
185 | protected $activePageWrapper = '%s';
186 |
187 | /**
188 | * Get disabled page wrapper HTML.
189 | *
190 | * @var string
191 | */
192 | protected $disabledPageWrapper = '%s';
193 |
194 | /**
195 | * Previous button text.
196 | *
197 | * @var string
198 | */
199 | protected $previousButtonText = '«';
200 |
201 | /**
202 | * Next button text.
203 | *
204 | * @var string
205 | */
206 | protected $nextButtonText = '»';
207 |
208 | /***
209 | * "Dots" text.
210 | *
211 | * @var string
212 | */
213 | protected $dotsText = '...';
214 |
215 | ...
216 |
217 | }
218 | ```
219 |
220 | Simply extend the `Landish\Pagination\Pagination` class in your `app/Pagination.php` file, just like I [recommended](#usage---recommended-way) above and overwrite these properties:
221 |
222 | ```php
223 | %s %s %s';
235 |
236 | ...
237 | }
238 | ```
239 |
240 | After that, just simply place the following code in your blade template file.
241 |
242 | ```php
243 | {!! (new App\Pagination($items))->render() !!}
244 | ```
245 |
246 | ## License
247 |
248 | The Landish/Pagination package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
249 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "landish/pagination",
3 | "description": "Laravel 5 Custom Pagination Presenter",
4 | "keywords": ["laravel", "pagination"],
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Lado Lomidze",
9 | "email": "lado.lomidze@gmail.com"
10 | }
11 | ],
12 | "autoload": {
13 | "psr-4": {
14 | "Landish\\Pagination\\": "src/"
15 | }
16 | },
17 | "require-dev": {
18 | "phpunit/phpunit": "~4.5",
19 | "illuminate/pagination": "5.2.*"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Materialize.php:
--------------------------------------------------------------------------------
1 | %s';
11 |
12 | /**
13 | * Get active page wrapper HTML.
14 | *
15 | * @var string
16 | */
17 | protected $activePageWrapper = '%s';
18 |
19 | /**
20 | * Get disabled page wrapper HTML.
21 | *
22 | * @var string
23 | */
24 | protected $disabledPageWrapper = '%s';
25 |
26 | /**
27 | * Previous button text.
28 | *
29 | * @var string
30 | */
31 | protected $previousButtonText = 'keyboard_arrow_left';
32 |
33 | /**
34 | * Next button text.
35 | *
36 | * @var string
37 | */
38 | protected $nextButtonText = 'keyboard_arrow_right';
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/Pagination.php:
--------------------------------------------------------------------------------
1 | paginator = $paginator;
35 | $this->window = is_null($window) ? UrlWindow::make($paginator) : $window->get();
36 | }
37 |
38 | /**
39 | * Determine if the underlying paginator being presented has pages to show.
40 | *
41 | * @return bool
42 | */
43 | public function hasPages()
44 | {
45 | return $this->paginator->hasPages();
46 | }
47 |
48 | /**
49 | * Convert the URL window into Pagination HTML.
50 | *
51 | * @return string
52 | */
53 | public function render()
54 | {
55 | if ($this->hasPages())
56 | {
57 | return sprintf(
58 | $this->getPaginationWrapperHTML(),
59 | $this->getPreviousButton(),
60 | $this->getLinks(),
61 | $this->getNextButton()
62 | );
63 | }
64 |
65 | return '';
66 | }
67 |
68 | /**
69 | * Get HTML wrapper for an available page link.
70 | *
71 | * @param string $url
72 | * @param int $page
73 | * @return string
74 | */
75 | protected function getAvailablePageWrapper($url, $page)
76 | {
77 | return sprintf($this->getAvailablePageWrapperHTML(),$url, $page);
78 | }
79 |
80 | /**
81 | * Get HTML wrapper for disabled text.
82 | *
83 | * @param string $text
84 | * @return string
85 | */
86 | protected function getDisabledTextWrapper($text)
87 | {
88 | return sprintf($this->getDisabledPageWrapperHTML(), $text);
89 | }
90 |
91 | /**
92 | * Get HTML wrapper for active text.
93 | *
94 | * @param string $text
95 | * @return string
96 | */
97 | protected function getActivePageWrapper($text)
98 | {
99 | return sprintf($this->getActivePageWrapperHTML(), $text);
100 | }
101 |
102 | /**
103 | * Get a pagination "dot" element.
104 | *
105 | * @return string
106 | */
107 | protected function getDots()
108 | {
109 | return $this->getDisabledTextWrapper($this->getDotsText());
110 | }
111 |
112 | /**
113 | * Get the current page from the paginator.
114 | *
115 | * @return int
116 | */
117 | protected function currentPage()
118 | {
119 | return $this->paginator->currentPage();
120 | }
121 |
122 | /**
123 | * Get the last page from the paginator.
124 | *
125 | * @return int
126 | */
127 | protected function lastPage()
128 | {
129 | return $this->paginator->lastPage();
130 | }
131 |
132 | /**
133 | * Get HTML wrapper for a page link.
134 | *
135 | * @param string $url
136 | * @param int $page
137 | * @return string
138 | */
139 | protected function getPageLinkWrapper($url, $page)
140 | {
141 | if ($page == $this->paginator->currentPage())
142 | {
143 | return $this->getActivePageWrapper($page);
144 | }
145 |
146 | return $this->getAvailablePageWrapper($url, $page);
147 | }
148 |
149 | /**
150 | * Get the previous page pagination element.
151 | *
152 | * @return string
153 | */
154 | protected function getPreviousButton()
155 | {
156 | // If the current page is less than or equal to one, it means we can't go any
157 | // further back in the pages, so we will render a disabled previous button
158 | // when that is the case. Otherwise, we will give it an active "status".
159 | if ($this->paginator->currentPage() <= 1) {
160 | return $this->getDisabledTextWrapper($this->getPreviousButtonText());
161 | }
162 |
163 | $url = $this->paginator->url(
164 | $this->paginator->currentPage() - 1
165 | );
166 |
167 | return $this->getPageLinkWrapper($url, $this->getPreviousButtonText());
168 | }
169 |
170 | /**
171 | * Get the next page pagination element.
172 | *
173 | * @return string
174 | */
175 | protected function getNextButton()
176 | {
177 | // If the current page is greater than or equal to the last page, it means we
178 | // can't go any further into the pages, as we're already on this last page
179 | // that is available, so we will make it the "next" link style disabled.
180 | if (!$this->paginator->hasMorePages()) {
181 | return $this->getDisabledTextWrapper($this->getNextButtonText());
182 | }
183 |
184 | $url = $this->paginator->url($this->paginator->currentPage() + 1);
185 |
186 | return $this->getPageLinkWrapper($url, $this->getNextButtonText());
187 | }
188 |
189 | }
190 |
--------------------------------------------------------------------------------
/src/PaginationHTML.php:
--------------------------------------------------------------------------------
1 | %s %s %s';
11 |
12 | /**
13 | * Available page wrapper HTML.
14 | *
15 | * @var string
16 | */
17 | protected $availablePageWrapper = '%s';
18 |
19 | /**
20 | * Get active page wrapper HTML.
21 | *
22 | * @var string
23 | */
24 | protected $activePageWrapper = '%s';
25 |
26 | /**
27 | * Get disabled page wrapper HTML.
28 | *
29 | * @var string
30 | */
31 | protected $disabledPageWrapper = '%s';
32 |
33 | /**
34 | * Previous button text.
35 | *
36 | * @var string
37 | */
38 | protected $previousButtonText = '«';
39 |
40 | /**
41 | * Next button text.
42 | *
43 | * @var string
44 | */
45 | protected $nextButtonText = '»';
46 |
47 | /***
48 | * "Dots" text.
49 | *
50 | * @var string
51 | */
52 | protected $dotsText = '...';
53 |
54 | /**
55 | * Get pagination wrapper HTML.
56 | *
57 | * @return string
58 | */
59 | protected function getPaginationWrapperHTML() {
60 | return $this->paginationWrapper;
61 | }
62 |
63 | /**
64 | * Get available page wrapper HTML.
65 | *
66 | * @return string
67 | */
68 | protected function getAvailablePageWrapperHTML() {
69 | return $this->availablePageWrapper;
70 | }
71 |
72 | /**
73 | * Get active page wrapper HTML.
74 | *
75 | * @return string
76 | */
77 | protected function getActivePageWrapperHTML() {
78 | return $this->activePageWrapper;
79 | }
80 |
81 | /**
82 | * Get disabled page wrapper HTML.
83 | *
84 | * @return string
85 | */
86 | protected function getDisabledPageWrapperHTML() {
87 | return $this->disabledPageWrapper;
88 | }
89 |
90 | /**
91 | * Get previous button text.
92 | *
93 | * @return string
94 | */
95 | protected function getPreviousButtonText() {
96 | return $this->previousButtonText;
97 | }
98 |
99 | /**
100 | * Get next button text.
101 | *
102 | * @return string
103 | */
104 | protected function getNextButtonText() {
105 | return $this->nextButtonText;
106 | }
107 |
108 | /***
109 | * Get "dots" text.
110 | *
111 | * @return string
112 | */
113 | protected function getDotsText() {
114 | return $this->dotsText;
115 | }
116 |
117 | }
--------------------------------------------------------------------------------
/src/SemanticUI.php:
--------------------------------------------------------------------------------
1 | %s %s %s';
11 |
12 | /**
13 | * Available page wrapper HTML.
14 | *
15 | * @var string
16 | */
17 | protected $availablePageWrapper = '%s';
18 |
19 | /**
20 | * Get active page wrapper HTML.
21 | *
22 | * @var string
23 | */
24 | protected $activePageWrapper = '%s
';
25 |
26 | /**
27 | * Get disabled page wrapper HTML.
28 | *
29 | * @var string
30 | */
31 | protected $disabledPageWrapper = '%s
';
32 |
33 | /**
34 | * Previous button text.
35 | *
36 | * @var string
37 | */
38 | protected $previousButtonText = '';
39 |
40 | /**
41 | * Next button text.
42 | *
43 | * @var string
44 | */
45 | protected $nextButtonText = '';
46 |
47 | }
--------------------------------------------------------------------------------
/src/Simple/Materialize.php:
--------------------------------------------------------------------------------
1 | paginator = $paginator;
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/Simple/Pagination.php:
--------------------------------------------------------------------------------
1 | %s %s %s';
14 |
15 | /**
16 | * Create a simple Pagination presenter.
17 | *
18 | * @param \Illuminate\Contracts\Pagination\Paginator $paginator
19 | */
20 | public function __construct(PaginatorContract $paginator)
21 | {
22 | $this->paginator = $paginator;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/Simple/SemanticUI.php:
--------------------------------------------------------------------------------
1 | paginator = $paginator;
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/Simple/UIKit.php:
--------------------------------------------------------------------------------
1 | paginator = $paginator;
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/Simple/ZurbFoundation.php:
--------------------------------------------------------------------------------
1 | paginator = $paginator;
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/UIKit.php:
--------------------------------------------------------------------------------
1 | %s %s %s';
11 |
12 | /**
13 | * Get disabled page wrapper HTML.
14 | *
15 | * @var string
16 | */
17 | protected $disabledPageWrapper = '%s';
18 |
19 | /**
20 | * Get active page wrapper HTML.
21 | *
22 | * @var string
23 | */
24 | protected $activePageWrapper = '%s';
25 |
26 | /**
27 | * Previous button text.
28 | *
29 | * @var string
30 | */
31 | protected $previousButtonText = '';
32 |
33 | /**
34 | * Next button text.
35 | *
36 | * @var string
37 | */
38 | protected $nextButtonText = '';
39 |
40 | }
--------------------------------------------------------------------------------
/src/ZurbFoundation.php:
--------------------------------------------------------------------------------
1 | %s';
11 |
12 | /**
13 | * Get disabled page wrapper HTML.
14 | *
15 | * @var string
16 | */
17 | protected $disabledPageWrapper = '%s';
18 |
19 | }
--------------------------------------------------------------------------------
/tests/BootstrapPaginationTest.php:
--------------------------------------------------------------------------------
1 | array[$i] = 'item' . $i;
13 | }
14 | $this->dir = __DIR__ . '/fixtures/bootstrap/';
15 | }
16 |
17 | public function testBootstrapPresenterCanGeneratorLinksForSlider() {
18 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
19 | $presenter = new BootstrapPresenter($p);
20 | $this->assertEquals(
21 | trim(file_get_contents($this->dir . 'slider.html')),
22 | $presenter->render()
23 | );
24 | }
25 |
26 | public function testBootstrapPresenterCanGeneratorLinksForTooCloseToBeginning() {
27 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
28 | $presenter = new BootstrapPresenter($p);
29 | $this->assertEquals(
30 | trim(file_get_contents($this->dir . 'beginning.html')),
31 | $presenter->render()
32 | );
33 | }
34 |
35 | public function testBootstrapPresenterCanGeneratorLinksForTooCloseToEnding() {
36 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
37 | $presenter = new BootstrapPresenter($p);
38 | $this->assertEquals(
39 | trim(file_get_contents($this->dir . 'ending.html')),
40 | $presenter->render()
41 | );
42 | }
43 |
44 | public function testBootstrapPresenterCanGeneratorLinksForWhenOnLastPage() {
45 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
46 | $presenter = new BootstrapPresenter($p);
47 | $this->assertEquals(
48 | trim(file_get_contents($this->dir . 'last_page.html')),
49 | $presenter->render()
50 | );
51 | }
52 |
53 | public function testBootstrapPresenterCanGeneratorLinksForWhenOnFirstPage() {
54 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
55 | $presenter = new BootstrapPresenter($p);
56 | $this->assertEquals(
57 | trim(file_get_contents($this->dir . 'first_page.html')),
58 | $presenter->render()
59 | );
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/tests/MaterializePaginationTest.php:
--------------------------------------------------------------------------------
1 | array[$i] = 'item' . $i;
13 | }
14 | $this->dir = __DIR__ . '/fixtures/materialize/';
15 | }
16 |
17 | public function testMaterializePresenterCanGenerateLinksForSlider() {
18 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
19 | $presenter = new MaterializePresenter($p);
20 | $this->assertEquals(
21 | trim(file_get_contents($this->dir . 'slider.html')),
22 | $presenter->render()
23 | );
24 | }
25 |
26 | public function testMaterializePresenterCanGenerateLinksForTooCloseToBegining() {
27 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
28 | $presenter = new MaterializePresenter($p);
29 | $this->assertEquals(
30 | trim(file_get_contents($this->dir . 'beginning.html')),
31 | $presenter->render()
32 | );
33 | }
34 |
35 | public function testMaterializePresenterCanGenerateLinksForTooCloseToEnding() {
36 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
37 | $presenter = new MaterializePresenter($p);
38 | $this->assertEquals(
39 | trim(file_get_contents($this->dir . 'ending.html')),
40 | $presenter->render()
41 | );
42 | }
43 |
44 | public function testMaterializePresenterCanGenerateLinksForLastPage() {
45 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
46 | $presenter = new MaterializePresenter($p);
47 | $this->assertEquals(
48 | trim(file_get_contents($this->dir . 'last_page.html')),
49 | $presenter->render()
50 | );
51 | }
52 |
53 | public function testMaterializePresenterCanGenerateLinksForFirstPage() {
54 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
55 | $presenter = new MaterializePresenter($p);
56 | $this->assertEquals(
57 | trim(file_get_contents($this->dir . 'first_page.html')),
58 | $presenter->render()
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/tests/SemanticUIPaginatonTest.php:
--------------------------------------------------------------------------------
1 | array[$i] = 'item' . $i;
13 | }
14 | $this->dir = __DIR__ . '/fixtures/semantic/';
15 | }
16 |
17 | public function testSemanticUIPresenterCanGeneratorLinksForSlider() {
18 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
19 | $presenter = new SemanticUIPresenter($p);
20 | $this->assertEquals(
21 | trim(file_get_contents($this->dir . 'slider.html')),
22 | $presenter->render()
23 | );
24 | }
25 |
26 | public function testSemanticUIPresenterCanGeneratorLinksForTooCloseToBeginning() {
27 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
28 | $presenter = new SemanticUIPresenter($p);
29 | $this->assertEquals(
30 | trim(file_get_contents($this->dir . 'beginning.html')),
31 | $presenter->render()
32 | );
33 | }
34 |
35 | public function testSemanticUIPresenterCanGeneratorLinksForTooCloseToEnding() {
36 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
37 | $presenter = new SemanticUIPresenter($p);
38 | $this->assertEquals(
39 | trim(file_get_contents($this->dir . 'ending.html')),
40 | $presenter->render()
41 | );
42 | }
43 |
44 | public function testSemanticUIPresenterCanGeneratorLinksForWhenOnLastPage() {
45 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
46 | $presenter = new SemanticUIPresenter($p);
47 | $this->assertEquals(
48 | trim(file_get_contents($this->dir . 'last_page.html')),
49 | $presenter->render()
50 | );
51 | }
52 |
53 | public function testSemanticUIPresenterCanGeneratorLinksForWhenOnFirstPage() {
54 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
55 | $presenter = new SemanticUIPresenter($p);
56 | $this->assertEquals(
57 | trim(file_get_contents($this->dir . 'first_page.html')),
58 | $presenter->render()
59 | );
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/tests/UIKitPaginationTest.php:
--------------------------------------------------------------------------------
1 | array[$i] = 'item' . $i;
13 | }
14 | $this->dir = __DIR__ . '/fixtures/uikit/';
15 | }
16 |
17 | public function testUIKitPresenterCanGeneratorLinksForSlider() {
18 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
19 | $presenter = new UIKitPresenter($p);
20 | $this->assertEquals(
21 | trim(file_get_contents($this->dir . 'slider.html')),
22 | $presenter->render()
23 | );
24 | }
25 |
26 | public function testUIKitPresenterCanGeneratorLinksForTooCloseToBeginning() {
27 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
28 | $presenter = new UIKitPresenter($p);
29 | $this->assertEquals(
30 | trim(file_get_contents($this->dir . 'beginning.html')),
31 | $presenter->render()
32 | );
33 | }
34 |
35 | public function testUIKitPresenterCanGeneratorLinksForTooCloseToEnding() {
36 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
37 | $presenter = new UIKitPresenter($p);
38 | $this->assertEquals(
39 | trim(file_get_contents($this->dir . 'ending.html')),
40 | $presenter->render()
41 | );
42 | }
43 |
44 | public function testUIKitPresenterCanGeneratorLinksForWhenOnLastPage() {
45 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
46 | $presenter = new UIKitPresenter($p);
47 | $this->assertEquals(
48 | trim(file_get_contents($this->dir . 'last_page.html')),
49 | $presenter->render()
50 | );
51 | }
52 |
53 | public function testUIKitPresenterCanGeneratorLinksForWhenOnFirstPage() {
54 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
55 | $presenter = new UIKitPresenter($p);
56 | $this->assertEquals(
57 | trim(file_get_contents($this->dir . 'first_page.html')),
58 | $presenter->render()
59 | );
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/tests/ZurbFoundationPaginationTest.php:
--------------------------------------------------------------------------------
1 | array[$i] = 'item' . $i;
13 | }
14 | $this->dir = __DIR__ . '/fixtures/foundation/';
15 | }
16 |
17 | public function testZurbFoundationPresenterCanGeneratorLinksForSlider() {
18 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 7);
19 | $presenter = new ZurbFoundationPresenter($p);
20 | $this->assertEquals(
21 | trim(file_get_contents($this->dir . 'slider.html')),
22 | $presenter->render()
23 | );
24 | }
25 |
26 | public function testZurbFoundationPresenterCanGeneratorLinksForTooCloseToBeginning() {
27 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 2);
28 | $presenter = new ZurbFoundationPresenter($p);
29 | $this->assertEquals(
30 | trim(file_get_contents($this->dir . 'beginning.html')),
31 | $presenter->render()
32 | );
33 | }
34 |
35 | public function testZurbFoundationPresenterCanGeneratorLinksForTooCloseToEnding() {
36 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 12);
37 | $presenter = new ZurbFoundationPresenter($p);
38 | $this->assertEquals(
39 | trim(file_get_contents($this->dir . 'ending.html')),
40 | $presenter->render()
41 | );
42 | }
43 |
44 | public function testZurbFoundationPresenterCanGeneratorLinksForWhenOnLastPage() {
45 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 13);
46 | $presenter = new ZurbFoundationPresenter($p);
47 | $this->assertEquals(
48 | trim(file_get_contents($this->dir . 'last_page.html')),
49 | $presenter->render()
50 | );
51 | }
52 |
53 | public function testZurbFoundationPresenterCanGeneratorLinksForWhenOnFirstPage() {
54 | $p = new LengthAwarePaginator($this->array, count($this->array), 1, 1);
55 | $presenter = new ZurbFoundationPresenter($p);
56 | $this->assertEquals(
57 | trim(file_get_contents($this->dir . 'first_page.html')),
58 | $presenter->render()
59 | );
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/tests/fixtures/bootstrap/beginning.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/bootstrap/ending.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/bootstrap/first_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/bootstrap/last_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/bootstrap/slider.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/foundation/beginning.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/foundation/ending.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/foundation/first_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/foundation/last_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/foundation/slider.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/materialize/beginning.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/fixtures/materialize/ending.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/fixtures/materialize/first_page.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/fixtures/materialize/last_page.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/fixtures/materialize/slider.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/fixtures/semantic/beginning.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/semantic/ending.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/semantic/first_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/semantic/last_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/semantic/slider.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/uikit/beginning.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/uikit/ending.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/uikit/first_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/uikit/last_page.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixtures/uikit/slider.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------