Fixes #3418, Model throws warnings when trying to save an empty array

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5804 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-10-19 21:05:34 +00:00
parent 981b8fed56
commit 5cb63a6460
2 changed files with 13 additions and 0 deletions

View file

@ -1048,6 +1048,11 @@ class Model extends Overloadable {
}
$this->set($data);
if (empty($this->data)) {
return false;
}
foreach (array('created', 'updated', 'modified') as $field) {
if (array_key_exists($field, $this->data[$this->name]) && $this->data[$this->name][$field] === null) {
unset($this->data[$this->name][$field]);

View file

@ -2854,6 +2854,14 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testSaveEmpty() {
$this->model =& new Article();
$data = array();
$expected = $this->model->save($data);
$this->assertFalse($expected);
}
/*function testBasicValidation() {
$this->model =& new ValidationTest();
$this->model->set(array('title' => '', 'published' => 1));