Skip to content

Commit

Permalink
Update tests for incorrect containable behaviour if a model only find…
Browse files Browse the repository at this point in the history
…s 1 field.
  • Loading branch information
thatcode committed Oct 25, 2013
1 parent 940a51b commit 456645d
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
Expand Up @@ -682,6 +682,65 @@ public function testFindSecondLevel() {
);
$this->assertEquals($expected, $result);

$this->Article->contain(array('User' => array('id', 'ArticleFeatured')));
$result = $this->Article->find('all', array('recursive' => 2));
$expected = array(
array(
'Article' => array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
'User' => array(
'id' => 1,
'ArticleFeatured' => array(
array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
)
)
)
),
array(
'Article' => array(
'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
),
'User' => array(
'id' => 3,
'ArticleFeatured' => array(
array(
'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
)
)
)
),
array(
'Article' => array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
),
'User' => array(
'id' => 1,
'ArticleFeatured' => array(
array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
)
)
)
)
);
$this->assertEquals($expected, $result);

$this->Article->contain(array('User' => array('ArticleFeatured', 'Comment')));
$result = $this->Article->find('all', array('recursive' => 2));
$expected = array(
Expand Down

0 comments on commit 456645d

Please sign in to comment.