Skip to content

Commit

Permalink
Test Controller::paginate() with custom settings
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez authored and markstory committed Jul 2, 2016
1 parent 8ded571 commit 271f572
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -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);

}

/**
Expand Down

0 comments on commit 271f572

Please sign in to comment.