Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Added tests for the new feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Yell committed Sep 1, 2014
1 parent dc9ce88 commit 9da43fa
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions Test/Case/Model/Behavior/ListableBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,44 @@ class ListableBehaviorTest extends CakeTestCase {
*/
public $autoFixtures = false;

/**
* Provide various configurations to the custom finder
*
* @return array
*/
public function customFindProvider() {
return [
[
[],
[
'contain' => [
'RelatedModel' => [
'fields' => ['id', 'name']
]
]
]
],
[
['fields' => ['id', 'title']],
[
'fields' => ['id', 'title'],
'contain' => [
'RelatedModel' => [
'fields' => ['id', 'name']
]
]
]
]
];
}

/**
* Make sure that the custom find method appends the conditions
*
* @dataProvider customFindProvider
* @return void
*/
public function testCustomFind() {
public function testCustomFind($query, $expected) {
$this->Model = new Model();
$this->Model->useTable = false;
$this->Model->primaryKey = 'id';
Expand All @@ -44,19 +76,8 @@ public function testCustomFind() {
);

$state = 'before';
$query = array();

$expected = array(
'fields' => array('id', 'display'),
'contain' => array(
'RelatedModel' => array(
'fields' => array('id','name')
)
)
);

$result = $this->Model->_findListing($state, $query);

$this->assertEqual($result, $expected);
}

Expand Down

0 comments on commit 9da43fa

Please sign in to comment.