1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pagerfanta\Tests\View; |
4
|
|
|
|
5
|
|
|
use Pagerfanta\View\SemanticUiView; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @author Loïc Frémont <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
class SemanticUiViewTest extends ViewTestCase |
11
|
|
|
{ |
12
|
|
|
protected function createView() |
13
|
|
|
{ |
14
|
|
|
return new SemanticUiView(); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function testRenderNormal() |
18
|
|
|
{ |
19
|
|
|
$this->setNbPages(100); |
20
|
|
|
$this->setCurrentPage(10); |
21
|
|
|
|
22
|
|
|
$options = array(); |
23
|
|
|
|
24
|
|
|
$this->assertRenderedView(<<<EOF |
25
|
|
|
<div class="ui stackable fluid pagination menu"> |
26
|
|
|
<a class="item prev" href="|9|">← Previous</a> |
27
|
|
|
<a class="item " href="|1|">1</a> |
28
|
|
|
<div class="item disabled">…</div> |
29
|
|
|
<a class="item " href="|7|">7</a> |
30
|
|
|
<a class="item " href="|8|">8</a> |
31
|
|
|
<a class="item " href="|9|">9</a> |
32
|
|
|
<div class="item active">10</div> |
33
|
|
|
<a class="item " href="|11|">11</a> |
34
|
|
|
<a class="item " href="|12|">12</a> |
35
|
|
|
<a class="item " href="|13|">13</a> |
36
|
|
|
<div class="item disabled">…</div> |
37
|
|
|
<a class="item " href="|100|">100</a> |
38
|
|
|
<a class="item next" href="|11|">Next →</a> |
39
|
|
|
</div> |
40
|
|
|
EOF |
41
|
|
|
, $this->renderView($options)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testRenderFirstPage() |
45
|
|
|
{ |
46
|
|
|
$this->setNbPages(100); |
47
|
|
|
$this->setCurrentPage(1); |
48
|
|
|
|
49
|
|
|
$options = array(); |
50
|
|
|
|
51
|
|
|
$this->assertRenderedView(<<<EOF |
52
|
|
|
<div class="ui stackable fluid pagination menu"> |
53
|
|
|
<div class="item prev disabled">← Previous</div> |
54
|
|
|
<div class="item active">1</div> |
55
|
|
|
<a class="item " href="|2|">2</a> |
56
|
|
|
<a class="item " href="|3|">3</a> |
57
|
|
|
<a class="item " href="|4|">4</a> |
58
|
|
|
<a class="item " href="|5|">5</a> |
59
|
|
|
<a class="item " href="|6|">6</a> |
60
|
|
|
<a class="item " href="|7|">7</a> |
61
|
|
|
<div class="item disabled">…</div> |
62
|
|
|
<a class="item " href="|100|">100</a> |
63
|
|
|
<a class="item next" href="|2|">Next →</a> |
64
|
|
|
</div> |
65
|
|
|
EOF |
66
|
|
|
, $this->renderView($options)); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testRenderLastPage() |
70
|
|
|
{ |
71
|
|
|
$this->setNbPages(100); |
72
|
|
|
$this->setCurrentPage(100); |
73
|
|
|
|
74
|
|
|
$options = array(); |
75
|
|
|
|
76
|
|
|
$this->assertRenderedView(<<<EOF |
77
|
|
|
<div class="ui stackable fluid pagination menu"> |
78
|
|
|
<a class="item prev" href="|99|">← Previous</a> |
79
|
|
|
<a class="item " href="|1|">1</a> |
80
|
|
|
<div class="item disabled">…</div> |
81
|
|
|
<a class="item " href="|94|">94</a> |
82
|
|
|
<a class="item " href="|95|">95</a> |
83
|
|
|
<a class="item " href="|96|">96</a> |
84
|
|
|
<a class="item " href="|97|">97</a> |
85
|
|
|
<a class="item " href="|98|">98</a> |
86
|
|
|
<a class="item " href="|99|">99</a> |
87
|
|
|
<div class="item active">100</div> |
88
|
|
|
<div class="item next disabled">Next →</div> |
89
|
|
|
</div> |
90
|
|
|
EOF |
91
|
|
|
, $this->renderView($options)); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function testRenderWhenStartProximityIs2() |
95
|
|
|
{ |
96
|
|
|
$this->setNbPages(100); |
97
|
|
|
$this->setCurrentPage(4); |
98
|
|
|
|
99
|
|
|
$options = array(); |
100
|
|
|
|
101
|
|
|
$this->assertRenderedView(<<<EOF |
102
|
|
|
<div class="ui stackable fluid pagination menu"> |
103
|
|
|
<a class="item prev" href="|3|">← Previous</a> |
104
|
|
|
<a class="item " href="|1|">1</a><a class="item " href="|2|">2</a> |
105
|
|
|
<a class="item " href="|3|">3</a> |
106
|
|
|
<div class="item active">4</div> |
107
|
|
|
<a class="item " href="|5|">5</a> |
108
|
|
|
<a class="item " href="|6|">6</a> |
109
|
|
|
<a class="item " href="|7|">7</a> |
110
|
|
|
<div class="item disabled">…</div> |
111
|
|
|
<a class="item " href="|100|">100</a> |
112
|
|
|
<a class="item next" href="|5|">Next →</a> |
113
|
|
|
</div> |
114
|
|
|
EOF |
115
|
|
|
, $this->renderView($options)); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function testRenderWhenStartProximityIs3() |
119
|
|
|
{ |
120
|
|
|
$this->setNbPages(100); |
121
|
|
|
$this->setCurrentPage(5); |
122
|
|
|
|
123
|
|
|
$options = array(); |
124
|
|
|
|
125
|
|
|
$this->assertRenderedView(<<<EOF |
126
|
|
|
<div class="ui stackable fluid pagination menu"> |
127
|
|
|
<a class="item prev" href="|4|">← Previous</a> |
128
|
|
|
<a class="item " href="|1|">1</a> |
129
|
|
|
<a class="item " href="|2|">2</a> |
130
|
|
|
<a class="item " href="|3|">3</a> |
131
|
|
|
<a class="item " href="|4|">4</a> |
132
|
|
|
<div class="item active">5</div> |
133
|
|
|
<a class="item " href="|6|">6</a> |
134
|
|
|
<a class="item " href="|7|">7</a> |
135
|
|
|
<a class="item " href="|8|">8</a> |
136
|
|
|
<div class="item disabled">…</div> |
137
|
|
|
<a class="item " href="|100|">100</a> |
138
|
|
|
<a class="item next" href="|6|">Next →</a> |
139
|
|
|
</div> |
140
|
|
|
EOF |
141
|
|
|
, $this->renderView($options)); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function testRenderWhenEndProximityIs2FromLast() |
145
|
|
|
{ |
146
|
|
|
$this->setNbPages(100); |
147
|
|
|
$this->setCurrentPage(97); |
148
|
|
|
|
149
|
|
|
$options = array(); |
150
|
|
|
|
151
|
|
|
$this->assertRenderedView(<<<EOF |
152
|
|
|
<div class="ui stackable fluid pagination menu"> |
153
|
|
|
<a class="item prev" href="|96|">← Previous</a> |
154
|
|
|
<a class="item " href="|1|">1</a> |
155
|
|
|
<div class="item disabled">…</div> |
156
|
|
|
<a class="item " href="|94|">94</a> |
157
|
|
|
<a class="item " href="|95|">95</a> |
158
|
|
|
<a class="item " href="|96|">96</a> |
159
|
|
|
<div class="item active">97</div> |
160
|
|
|
<a class="item " href="|98|">98</a> |
161
|
|
|
<a class="item " href="|99|">99</a> |
162
|
|
|
<a class="item " href="|100|">100</a> |
163
|
|
|
<a class="item next" href="|98|">Next →</a> |
164
|
|
|
</div> |
165
|
|
|
EOF |
166
|
|
|
, $this->renderView($options)); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function testRenderWhenEndProximityIs3FromLast() |
170
|
|
|
{ |
171
|
|
|
$this->setNbPages(100); |
172
|
|
|
$this->setCurrentPage(96); |
173
|
|
|
|
174
|
|
|
$options = array(); |
175
|
|
|
|
176
|
|
|
$this->assertRenderedView(<<<EOF |
177
|
|
|
<div class="ui stackable fluid pagination menu"> |
178
|
|
|
<a class="item prev" href="|95|">← Previous</a> |
179
|
|
|
<a class="item " href="|1|">1</a> |
180
|
|
|
<div class="item disabled">…</div> |
181
|
|
|
<a class="item " href="|93|">93</a> |
182
|
|
|
<a class="item " href="|94|">94</a> |
183
|
|
|
<a class="item " href="|95|">95</a> |
184
|
|
|
<div class="item active">96</div> |
185
|
|
|
<a class="item " href="|97|">97</a> |
186
|
|
|
<a class="item " href="|98|">98</a> |
187
|
|
|
<a class="item " href="|99|">99</a> |
188
|
|
|
<a class="item " href="|100|">100</a> |
189
|
|
|
<a class="item next" href="|97|">Next →</a> |
190
|
|
|
</div> |
191
|
|
|
EOF |
192
|
|
|
, $this->renderView($options)); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function testRenderModifyingProximity() |
196
|
|
|
{ |
197
|
|
|
$this->setNbPages(100); |
198
|
|
|
$this->setCurrentPage(10); |
199
|
|
|
|
200
|
|
|
$options = array('proximity' => 2); |
201
|
|
|
|
202
|
|
|
$this->assertRenderedView(<<<EOF |
203
|
|
|
<div class="ui stackable fluid pagination menu"> |
204
|
|
|
<a class="item prev" href="|9|">← Previous</a> |
205
|
|
|
<a class="item " href="|1|">1</a> |
206
|
|
|
<div class="item disabled">…</div> |
207
|
|
|
<a class="item " href="|8|">8</a> |
208
|
|
|
<a class="item " href="|9|">9</a> |
209
|
|
|
<div class="item active">10</div> |
210
|
|
|
<a class="item " href="|11|">11</a> |
211
|
|
|
<a class="item " href="|12|">12</a> |
212
|
|
|
<div class="item disabled">…</div> |
213
|
|
|
<a class="item " href="|100|">100</a> |
214
|
|
|
<a class="item next" href="|11|">Next →</a> |
215
|
|
|
</div> |
216
|
|
|
EOF |
217
|
|
|
, $this->renderView($options)); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function testRenderModifyingPreviousAndNextMessages() |
221
|
|
|
{ |
222
|
|
|
$this->setNbPages(100); |
223
|
|
|
$this->setCurrentPage(10); |
224
|
|
|
|
225
|
|
|
$options = array( |
226
|
|
|
'prev_message' => 'Anterior', |
227
|
|
|
'next_message' => 'Siguiente', |
228
|
|
|
); |
229
|
|
|
|
230
|
|
|
$this->assertRenderedView(<<<EOF |
231
|
|
|
<div class="ui stackable fluid pagination menu"> |
232
|
|
|
<a class="item prev" href="|9|">Anterior</a> |
233
|
|
|
<a class="item " href="|1|">1</a> |
234
|
|
|
<div class="item disabled">…</div> |
235
|
|
|
<a class="item " href="|7|">7</a> |
236
|
|
|
<a class="item " href="|8|">8</a> |
237
|
|
|
<a class="item " href="|9|">9</a> |
238
|
|
|
<div class="item active">10</div> |
239
|
|
|
<a class="item " href="|11|">11</a> |
240
|
|
|
<a class="item " href="|12|">12</a> |
241
|
|
|
<a class="item " href="|13|">13</a> |
242
|
|
|
<div class="item disabled">…</div> |
243
|
|
|
<a class="item " href="|100|">100</a> |
244
|
|
|
<a class="item next" href="|11|">Siguiente</a> |
245
|
|
|
</div> |
246
|
|
|
EOF |
247
|
|
|
, $this->renderView($options)); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
public function testRenderModifyingCssClasses() |
251
|
|
|
{ |
252
|
|
|
$this->setNbPages(100); |
253
|
|
|
$this->setCurrentPage(1); |
254
|
|
|
|
255
|
|
|
$options = array( |
256
|
|
|
'css_container_class' => 'paginacion', |
257
|
|
|
'css_item_class' => 'itemo', |
258
|
|
|
'css_prev_class' => 'anterior', |
259
|
|
|
'css_next_class' => 'siguiente', |
260
|
|
|
'css_disabled_class' => 'deshabilitado', |
261
|
|
|
'css_dots_class' => 'puntos', |
262
|
|
|
'css_active_class' => 'activo', |
263
|
|
|
); |
264
|
|
|
|
265
|
|
|
$this->assertRenderedView(<<<EOF |
266
|
|
|
<div class="paginacion"> |
267
|
|
|
<div class="itemo anterior deshabilitado">← Previous</div> |
268
|
|
|
<div class="itemo activo">1</div> |
269
|
|
|
<a class="itemo " href="|2|">2</a> |
270
|
|
|
<a class="itemo " href="|3|">3</a> |
271
|
|
|
<a class="itemo " href="|4|">4</a> |
272
|
|
|
<a class="itemo " href="|5|">5</a> |
273
|
|
|
<a class="itemo " href="|6|">6</a> |
274
|
|
|
<a class="itemo " href="|7|">7</a> |
275
|
|
|
<div class="itemo puntos">…</div> |
276
|
|
|
<a class="itemo " href="|100|">100</a> |
277
|
|
|
<a class="itemo siguiente" href="|2|">Next →</a> |
278
|
|
|
</div> |
279
|
|
|
EOF |
280
|
|
|
, $this->renderView($options)); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
protected function filterExpectedView($expected) |
284
|
|
|
{ |
285
|
|
|
return $this->removeWhitespacesBetweenTags($expected); |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
|