4
4
5
5
use Bootstrap \View \Helper \PaginatorHelper ;
6
6
use Cake \Core \Configure ;
7
- use Cake \Network \ Request ;
7
+ use Cake \Http \ ServerRequest ;
8
8
use Cake \Routing \Router ;
9
9
use Cake \TestSuite \TestCase ;
10
10
use Cake \View \View ;
@@ -26,25 +26,29 @@ class PaginatorHelperTest extends TestCase {
26
26
public function setUp ()
27
27
{
28
28
parent ::setUp ();
29
- $ view = new View ();
29
+ $ request = new ServerRequest ([
30
+ 'url ' => '/ ' ,
31
+ 'params ' => [
32
+ 'paging ' => [
33
+ 'Article ' => [
34
+ 'page ' => 1 ,
35
+ 'current ' => 9 ,
36
+ 'count ' => 62 ,
37
+ 'prevPage ' => false ,
38
+ 'nextPage ' => true ,
39
+ 'pageCount ' => 7 ,
40
+ 'sort ' => null ,
41
+ 'direction ' => null ,
42
+ 'limit ' => null ,
43
+ ]
44
+ ]
45
+ ]
46
+ ]);
47
+ $ view = new View ($ request );
30
48
$ view ->loadHelper ('Html ' , [
31
49
'className ' => 'Bootstrap.Html '
32
50
]);
33
51
$ this ->paginator = new PaginatorHelper ($ view );
34
- $ this ->paginator ->request = (new Request ())
35
- ->withParam ('paging ' , [
36
- 'Article ' => [
37
- 'page ' => 1 ,
38
- 'current ' => 9 ,
39
- 'count ' => 62 ,
40
- 'prevPage ' => false ,
41
- 'nextPage ' => true ,
42
- 'pageCount ' => 7 ,
43
- 'sort ' => null ,
44
- 'direction ' => null ,
45
- 'limit ' => null ,
46
- ]
47
- ]);
48
52
Configure::write ('Routing.prefixes ' , []);
49
53
Router::reload ();
50
54
Router::connect ('/:controller/:action/* ' );
@@ -53,7 +57,7 @@ public function setUp()
53
57
54
58
public function testNumbers ()
55
59
{
56
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
60
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
57
61
'Client ' => [
58
62
'page ' => 8 ,
59
63
'current ' => 3 ,
@@ -62,7 +66,7 @@ public function testNumbers()
62
66
'nextPage ' => 2 ,
63
67
'pageCount ' => 15 ,
64
68
]
65
- ]);
69
+ ])) ;
66
70
$ result = $ this ->paginator ->numbers ();
67
71
$ expected = [
68
72
['ul ' => ['class ' => 'pagination ' ]],
@@ -135,7 +139,7 @@ public function testNumbers()
135
139
'/ul '
136
140
];
137
141
$ this ->assertHtml ($ expected , $ result );
138
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
142
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
139
143
'Client ' => [
140
144
'page ' => 1 ,
141
145
'current ' => 3 ,
@@ -144,7 +148,7 @@ public function testNumbers()
144
148
'nextPage ' => 2 ,
145
149
'pageCount ' => 15 ,
146
150
]
147
- ]);
151
+ ])) ;
148
152
$ result = $ this ->paginator ->numbers ();
149
153
$ expected = [
150
154
['ul ' => ['class ' => 'pagination ' ]],
@@ -160,7 +164,7 @@ public function testNumbers()
160
164
'/ul '
161
165
];
162
166
$ this ->assertHtml ($ expected , $ result );
163
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
167
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
164
168
'Client ' => [
165
169
'page ' => 14 ,
166
170
'current ' => 3 ,
@@ -169,7 +173,7 @@ public function testNumbers()
169
173
'nextPage ' => 2 ,
170
174
'pageCount ' => 15 ,
171
175
]
172
- ]);
176
+ ])) ;
173
177
$ result = $ this ->paginator ->numbers ();
174
178
$ expected = [
175
179
['ul ' => ['class ' => 'pagination ' ]],
@@ -185,7 +189,7 @@ public function testNumbers()
185
189
'/ul '
186
190
];
187
191
$ this ->assertHtml ($ expected , $ result );
188
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
192
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
189
193
'Client ' => [
190
194
'page ' => 2 ,
191
195
'current ' => 3 ,
@@ -194,7 +198,7 @@ public function testNumbers()
194
198
'nextPage ' => 2 ,
195
199
'pageCount ' => 9 ,
196
200
]
197
- ]);
201
+ ])) ;
198
202
$ result = $ this ->paginator ->numbers (['first ' => 1 ]);
199
203
$ expected = [
200
204
['ul ' => ['class ' => 'pagination ' ]],
@@ -225,7 +229,7 @@ public function testNumbers()
225
229
'/ul '
226
230
];
227
231
$ this ->assertHtml ($ expected , $ result );
228
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
232
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
229
233
'Client ' => [
230
234
'page ' => 15 ,
231
235
'current ' => 3 ,
@@ -234,7 +238,7 @@ public function testNumbers()
234
238
'nextPage ' => 2 ,
235
239
'pageCount ' => 15 ,
236
240
]
237
- ]);
241
+ ])) ;
238
242
$ result = $ this ->paginator ->numbers (['first ' => 1 ]);
239
243
$ expected = [
240
244
['ul ' => ['class ' => 'pagination ' ]],
@@ -252,7 +256,7 @@ public function testNumbers()
252
256
'/ul '
253
257
];
254
258
$ this ->assertHtml ($ expected , $ result );
255
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
259
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
256
260
'Client ' => [
257
261
'page ' => 10 ,
258
262
'current ' => 3 ,
@@ -261,7 +265,7 @@ public function testNumbers()
261
265
'nextPage ' => 2 ,
262
266
'pageCount ' => 15 ,
263
267
]
264
- ]);
268
+ ])) ;
265
269
$ result = $ this ->paginator ->numbers (['first ' => 1 , 'last ' => 1 ]);
266
270
$ expected = [
267
271
['ul ' => ['class ' => 'pagination ' ]],
@@ -280,7 +284,7 @@ public function testNumbers()
280
284
'/ul '
281
285
];
282
286
$ this ->assertHtml ($ expected , $ result );
283
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
287
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
284
288
'Client ' => [
285
289
'page ' => 6 ,
286
290
'current ' => 15 ,
@@ -289,7 +293,7 @@ public function testNumbers()
289
293
'nextPage ' => 1 ,
290
294
'pageCount ' => 42 ,
291
295
]
292
- ]);
296
+ ])) ;
293
297
$ result = $ this ->paginator ->numbers (['first ' => 1 , 'last ' => 1 ]);
294
298
$ expected = [
295
299
['ul ' => ['class ' => 'pagination ' ]],
@@ -308,7 +312,7 @@ public function testNumbers()
308
312
'/ul '
309
313
];
310
314
$ this ->assertHtml ($ expected , $ result );
311
- $ this ->paginator ->request = $ this ->paginator ->request ->withParam ('paging ' , [
315
+ $ this ->paginator ->getView ()-> setRequest ( $ this ->paginator ->getView ()-> getRequest () ->withParam ('paging ' , [
312
316
'Client ' => [
313
317
'page ' => 37 ,
314
318
'current ' => 15 ,
@@ -317,7 +321,7 @@ public function testNumbers()
317
321
'nextPage ' => 1 ,
318
322
'pageCount ' => 42 ,
319
323
]
320
- ]);
324
+ ])) ;
321
325
$ result = $ this ->paginator ->numbers (['first ' => 1 , 'last ' => 1 ]);
322
326
$ expected = [
323
327
['ul ' => ['class ' => 'pagination ' ]],
0 commit comments