Fix for Model::saveAll validate => first, closes #4533

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6825 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2008-05-13 01:39:06 +00:00
parent 823eb81dc7
commit d9a30eaa62
2 changed files with 22 additions and 1 deletions

View file

@ -1335,7 +1335,7 @@ class Model extends Overloadable {
break;
}
}
return $validates;
return $return;
}
$associations = $this->getAssociated();

View file

@ -2337,6 +2337,27 @@ class ModelTest extends CakeTestCase {
$result = $this->model->saveAll($data, array('validate' => 'only'));
$this->assertFalse($result);
}
function testSaveAllValidateFirst() {
$this->model =& new Article();
$this->model->deleteAll(true);
$this->model->Comment->validate = array('comment' => VALID_NOT_EMPTY);
$result = $this->model->saveAll(array(
'Article' => array('title' => 'Post with Author', 'body' => 'This post will be saved author'),
'Comment' => array(
array('comment' => 'First new comment'),
array('comment' => '')
)
), array('validate' => 'first'));
$this->assertFalse($result);
$result = $this->model->find('all');
$this->assertEqual($result, array());
$expected = array('Comment' => array(0 => array('comment' => 'This field cannot be left blank')));
$this->assertEqual($this->model->validationErrors, $expected);
}
function testSaveWithCounterCache() {
$this->loadFixtures('Syfile', 'Item');