Skip to content

Commit

Permalink
Adding test to disprove issue. Closes #4693
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8124 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
mariano.iglesias committed Mar 22, 2009
1 parent fd7d671 commit 364fe18
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cake/tests/cases/libs/model/behaviors/containable.test.php
Expand Up @@ -51,6 +51,7 @@ class ContainableBehaviorTest extends CakeTestCase {
function startTest() {
$this->User =& ClassRegistry::init('User');
$this->Article =& ClassRegistry::init('Article');
$this->Tag =& ClassRegistry::init('Tag');

$this->User->bind(array(
'Article' => array('type' => 'hasMany'),
Expand All @@ -60,8 +61,13 @@ function startTest() {
$this->User->ArticleFeatured->unbindModel(array('belongsTo' => array('Category')), false);
$this->User->ArticleFeatured->hasMany['Comment']['foreignKey'] = 'article_id';

$this->Tag->bind(array(
'Article' => array('type' => 'hasAndBelongsToMany')
));

$this->User->Behaviors->attach('Containable');
$this->Article->Behaviors->attach('Containable');
$this->Tag->Behaviors->attach('Containable');
}
/**
* Method executed after each test
Expand All @@ -71,6 +77,7 @@ function startTest() {
function endTest() {
unset($this->Article);
unset($this->User);
unset($this->Tag);

ClassRegistry::flush();
}
Expand Down Expand Up @@ -124,6 +131,16 @@ function testContainments() {
$this->assertEqual(array_shift(Set::extract('/User/keep', $r)), array('keep' => array()));
$this->assertEqual(array_shift(Set::extract('/Comment/keep', $r)), array('keep' => array('User' => array())));
$this->assertEqual(array_shift(Set::extract('/Article/keep', $r)), array('keep' => array('Comment' => array())));

$r = $this->__containments($this->Tag, array('Article' => array('User' => array('Comment' => array(
'Attachment' => array('conditions' => array('Attachment.id >' => 1))
)))));
$this->assertTrue(Set::matches('/Attachment', $r));
$this->assertTrue(Set::matches('/Comment/keep/Attachment/conditions', $r));
$this->assertEqual($r['Comment']['keep']['Attachment']['conditions'], array('Attachment.id >' => 1));
$this->assertTrue(Set::matches('/User/keep/Comment', $r));
$this->assertTrue(Set::matches('/Article/keep/User', $r));
$this->assertTrue(Set::matches('/Tag/keep/Article', $r));
}
/**
* testInvalidContainments method
Expand Down Expand Up @@ -3540,4 +3557,4 @@ function __bindings(&$Model, $extra = array(), $output = true) {
return $debug;
}
}
?>
?>

0 comments on commit 364fe18

Please sign in to comment.