From 616682decd69aa1d08b61b84dfa3e4762f21d947 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Sat, 2 Aug 2008 00:50:40 +0000 Subject: [PATCH] Added tests to save data with non existent fields. Closes #5154 as invalid git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7417 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/cases/libs/model/model.test.php | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index a61953f77..4bdba41de 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -2299,6 +2299,57 @@ class ModelTest extends CakeTestCase { ); $this->assertEqual($result, $expected); } +/** + * testSaveWithNonExistentFields method + * + * @access public + * @return void + */ + function testSaveWithNonExistentFields() { + $this->loadFixtures('Article'); + $TestModel =& new Article(); + $TestModel->recursive = -1; + + $data = array( + 'non_existent' => 'This field does not exist', + 'user_id' => '1', + 'title' => 'Fourth Article - New Title', + 'body' => 'Fourth Article Body', + 'published' => 'N' + ); + $result = $TestModel->create() && $TestModel->save($data); + $this->assertTrue($result); + + $expected = array('Article' => array( + 'id' => '4', + 'user_id' => '1', + 'title' => 'Fourth Article - New Title', + 'body' => 'Fourth Article Body', + 'published' => 'N' + )); + $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); + $this->assertEqual($result, $expected); + + $data = array( + 'user_id' => '1', + 'non_existent' => 'This field does not exist', + 'title' => 'Fiveth Article - New Title', + 'body' => 'Fiveth Article Body', + 'published' => 'N' + ); + $result = $TestModel->create() && $TestModel->save($data); + $this->assertTrue($result); + + $expected = array('Article' => array( + 'id' => '5', + 'user_id' => '1', + 'title' => 'Fiveth Article - New Title', + 'body' => 'Fiveth Article Body', + 'published' => 'N' + )); + $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); + $this->assertEqual($result, $expected); + } /** * testSaveFromXml method *