Skip to content

Commit

Permalink
Add tests for mergeOptions with custom prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez authored and markstory committed Jul 2, 2016
1 parent ed233e7 commit 8ded571
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/TestCase/Controller/Component/PaginatorComponentTest.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 8ded571

Please sign in to comment.