Adding test case to show how auto-computed fields should be removed from data if using to clone records, closes #6066

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8019 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2009-02-07 14:56:37 +00:00
parent f7dd0800d1
commit b71457f332

View file

@ -994,6 +994,18 @@ class ModelTest extends CakeTestCase {
$expected = array('Article' => array('published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text'));
$this->assertEqual($result, $expected);
$this->assertFalse($TestModel->id);
$data = array('id' => 6, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text', 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00');
$result = $TestModel->create($data);
$expected = array('Article' => array('published' => 'N', 'id' => 6, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text', 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00'));
$this->assertEqual($result, $expected);
$this->assertEqual($TestModel->id, 6);
$result = $TestModel->create(array('Article' => array_diff_key($data, array('created' => true, 'updated' => true, 'modified' => true))), true);
$expected = array('Article' => array('published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text'));
$this->assertEqual($result, $expected);
$this->assertFalse($TestModel->id);
}
/**
* testCreationWithMultipleData method
@ -6456,4 +6468,4 @@ class ModelTest extends CakeTestCase {
}
}
?>
?>