Skip to content
Permalink
Browse files

Add tests for mergeOptions with custom prefix

  • Loading branch information...
josegonzalez authored and markstory committed May 1, 2016
1 parent ed233e7 commit 8ded571b4813f3657c1ff5d8347a506f5be5db60
Showing with 70 additions and 0 deletions.
  1. +70 −0 tests/TestCase/Controller/Component/PaginatorComponentTest.php
@@ -291,6 +291,76 @@ public function testMergeOptionsModelSpecific()
$this->assertEquals($expected, $result);
}
/**
* test mergeOptions with custom prefix
*
* @return void
*/
public function testMergeOptionsCustomPrefix()
{
$this->request->query = [
'page' => 10,
'limit' => 10,
'prefix' => [
'page' => 2,
'limit' => 5,
]
];
$settings = [
'page' => 1,
'limit' => 20,
'maxLimit' => 100,
'finder' => 'myCustomFind',
];
$result = $this->Paginator->mergeOptions('Post', $settings);
$expected = [
'page' => 10,
'limit' => 10,
'maxLimit' => 100,
'finder' => 'myCustomFind',
'whitelist' => ['limit', 'sort', 'page', 'direction'],
];
$this->assertEquals($expected, $result);
$settings = [
'page' => 1,
'limit' => 20,
'maxLimit' => 100,
'finder' => 'myCustomFind',
'prefix' => 'non-existent',
];
$result = $this->Paginator->mergeOptions('Post', $settings);
$expected = [
'page' => 1,
'limit' => 20,
'maxLimit' => 100,
'finder' => 'myCustomFind',
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => 'non-existent',
];
$this->assertEquals($expected, $result);
$settings = [
'page' => 1,
'limit' => 20,
'maxLimit' => 100,
'finder' => 'myCustomFind',
'prefix' => 'prefix',
];
$result = $this->Paginator->mergeOptions('Post', $settings);
$expected = [
'page' => 2,
'limit' => 5,
'maxLimit' => 100,
'finder' => 'myCustomFind',
'whitelist' => ['limit', 'sort', 'page', 'direction'],
'prefix' => 'prefix',
];
$this->assertEquals($expected, $result);
}
/**
* test mergeOptions with customFind key
*

0 comments on commit 8ded571

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