mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7340 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
029f2ab75c
commit
8bbc0d7078
1 changed files with 89 additions and 0 deletions
|
@ -3320,7 +3320,96 @@ class ContainableTest extends CakeTestCase {
|
||||||
$result = $this->Article->Comment->find('all', $initialOptions);
|
$result = $this->Article->Comment->find('all', $initialOptions);
|
||||||
$this->assertEqual($result, $initialModels);
|
$this->assertEqual($result, $initialModels);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testResetMultipleHabtmAssociations method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testResetMultipleHabtmAssociations() {
|
||||||
|
$articleHabtm = array(
|
||||||
|
'hasAndBelongsToMany' => array(
|
||||||
|
'Tag' => array(
|
||||||
|
'className' => 'Tag',
|
||||||
|
'joinTable' => 'articles_tags',
|
||||||
|
'foreignKey' => 'article_id',
|
||||||
|
'associationForeignKey' => 'tag_id'
|
||||||
|
),
|
||||||
|
'ShortTag' => array(
|
||||||
|
'className' => 'Tag',
|
||||||
|
'joinTable' => 'articles_tags',
|
||||||
|
'foreignKey' => 'article_id',
|
||||||
|
'associationForeignKey' => 'tag_id',
|
||||||
|
'conditions' => 'LENGTH(ShortTag.tag) <= 3'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all');
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => 'Tag.tag'));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => 'Tag'));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('Tag' => array('fields' => array(null)))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('Tag' => array('fields' => array('Tag.tag')))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('Tag' => array('fields' => array('Tag.tag', 'Tag.created')))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => 'ShortTag.tag'));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => 'ShortTag'));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array(null)))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array('ShortTag.tag')))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
|
||||||
|
$this->Article->resetBindings();
|
||||||
|
$this->Article->bindModel($articleHabtm, false);
|
||||||
|
$expected = $this->Article->hasAndBelongsToMany;
|
||||||
|
$this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array('ShortTag.tag', 'ShortTag.created')))));
|
||||||
|
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* containments method
|
* containments method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue