mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
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
This commit is contained in:
parent
9e9775ee53
commit
616682decd
1 changed files with 51 additions and 0 deletions
|
@ -2299,6 +2299,57 @@ class ModelTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$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
|
* testSaveFromXml method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue