adding model test, closes #5819

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7917 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-12-12 16:10:11 +00:00
parent 3682c9c6ae
commit 24cc66b43e

View file

@ -3000,6 +3000,45 @@ class ModelTest extends CakeTestCase {
);
$this->assertEqual($result['Monkey'], $expected);
}
/**
* testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method
*
* @access public
* @return void
*/
function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() {
$this->loadFixtures('Apple', 'Device', 'ThePaperMonkies');
$ThePaper =& new ThePaper();
$ThePaper->id = 1;
$ThePaper->save(array('Monkey' => array(2, 3)));
$result = $ThePaper->findById(1);
$expected = array(
array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'),
array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')
);
$this->assertEqual($result['Monkey'], $expected);
$ThePaper =& new ThePaper();
$ThePaper->id = 2;
$ThePaper->save(array('Monkey' => array(2, 3)));
$result = $ThePaper->findById(2);
$expected = array(
array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'),
array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')
);
$this->assertEqual($result['Monkey'], $expected);
$ThePaper->delete(1);
$result = $ThePaper->findById(2);
$expected = array(
array('id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1'),
array('id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2')
);
$this->assertEqual($result['Monkey'], $expected);
}
/**
* test that Caches are getting cleared on save().
* ensure that both inflections of controller names are getting cleared