From b71457f3323b2487298367408b481fa20f603b08 Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Sat, 7 Feb 2009 14:56:37 +0000 Subject: [PATCH] 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 --- cake/tests/cases/libs/model/model.test.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 968bfdc03..44ee8b3b5 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -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 { } } -?> \ No newline at end of file +?>