File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
tests/TestCase/Controller/Component Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -181,4 +181,40 @@ public function testKeySetting()
181
181
182
182
$ this ->assertSame ($ expected , $ result );
183
183
}
184
+
185
+ public function testAllSettings ()
186
+ {
187
+ $ request = new Request ('/articles ' );
188
+ $ request ->env ('HTTP_ACCEPT ' , 'application/json ' );
189
+ $ response = $ this ->getMock ('Cake\Network\Response ' );
190
+ $ controller = new ArticlesController ($ request , $ response );
191
+ $ controller ->set ('data ' , $ controller ->paginate ($ this ->Articles ));
192
+ $ apiPaginationComponent = new ApiPaginationComponent ($ controller ->components (), [
193
+ 'key ' => 'fun ' ,
194
+ 'aliases ' => [
195
+ 'page ' => 'currentPage ' ,
196
+ 'count ' => 'totalCount ' ,
197
+ 'limit ' => 'unusedAlias '
198
+ ],
199
+ 'visible ' => [
200
+ 'currentPage ' ,
201
+ 'totalCount ' ,
202
+ 'limit ' ,
203
+ 'prevPage ' ,
204
+ 'nextPage '
205
+ ]
206
+ ]);
207
+ $ event = new Event ('Controller.beforeRender ' , $ controller );
208
+ $ apiPaginationComponent ->beforeRender ($ event );
209
+
210
+ $ result = $ apiPaginationComponent ->_registry ->getController ()->viewVars ['fun ' ];
211
+ $ expected = [
212
+ 'prevPage ' => false ,
213
+ 'nextPage ' => true ,
214
+ 'currentPage ' => 1 ,
215
+ 'totalCount ' => 23 ,
216
+ ];
217
+
218
+ $ this ->assertSame ($ expected , $ result );
219
+ }
184
220
}
You can’t perform that action at this time.
0 commit comments