Skip to content
Permalink
Browse files

Test Controller::paginate() with custom settings

  • Loading branch information...
josegonzalez authored and markstory committed May 1, 2016
1 parent 8ded571 commit 271f5721ba135a8f3cb660b856a3395707d75c1f
Showing with 20 additions and 1 deletion.
  1. +20 −1 tests/TestCase/Controller/ControllerTest.php
@@ -726,22 +726,41 @@ public function testPaginate()
->getMock();
$Controller = new Controller($request, $response);
$Controller->request->query['url'] = [];
$Controller->request->query = [
'url' => [],
'prefix' => [
'page' => 2,
'limit' => 2,
]
];
$this->assertEquals([], $Controller->paginate);
$this->assertNotContains('Paginator', $Controller->helpers);
$this->assertArrayNotHasKey('Paginator', $Controller->helpers);
$results = $Controller->paginate('Posts');
$this->assertInstanceOf('Cake\Datasource\ResultSetInterface', $results);
$this->assertCount(3, $results);
$results = $Controller->paginate(TableRegistry::get('Posts'));
$this->assertInstanceOf('Cake\Datasource\ResultSetInterface', $results);
$this->assertCount(3, $results);
$this->assertSame($Controller->request->params['paging']['Posts']['page'], 1);
$this->assertSame($Controller->request->params['paging']['Posts']['pageCount'], 1);
$this->assertSame($Controller->request->params['paging']['Posts']['prevPage'], false);
$this->assertSame($Controller->request->params['paging']['Posts']['nextPage'], false);
$results = $Controller->paginate(TableRegistry::get('Posts'), ['prefix' => 'prefix']);
$this->assertInstanceOf('Cake\Datasource\ResultSetInterface', $results);
$this->assertCount(1, $results);
$this->assertSame($Controller->request->params['paging']['Posts']['page'], 2);
$this->assertSame($Controller->request->params['paging']['Posts']['pageCount'], 2);
$this->assertSame($Controller->request->params['paging']['Posts']['prevPage'], true);
$this->assertSame($Controller->request->params['paging']['Posts']['nextPage'], false);
}
/**

0 comments on commit 271f572

Please sign in to comment.
You can’t perform that action at this time.