mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
823eb81dc7
commit
d9a30eaa62
2 changed files with 22 additions and 1 deletions
|
@ -1335,7 +1335,7 @@ class Model extends Overloadable {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return $validates;
|
||||
return $return;
|
||||
}
|
||||
$associations = $this->getAssociated();
|
||||
|
||||
|
|
|
@ -2338,6 +2338,27 @@ class ModelTest extends CakeTestCase {
|
|||
$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');
|
||||
$this->model =& new Syfile();
|
||||
|
|
Loading…
Reference in a new issue