diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 835de0a71b1..7b58af7b67c 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -5641,34 +5641,31 @@ public function testSaveAllFieldListHasOne() { $this->loadFixtures('Attachment', 'Comment', 'Article', 'User'); $TestModel = new Comment(); - $expected = $TestModel->find('first', array( - 'conditions' => array('Comment.id' => 5), - 'recursive' => 0 - )); + $TestModel->validate = array('comment' => 'notEmpty'); + $TestModel->Attachment->validate = array('attachment' => 'notEmpty'); - $fieldList = array( - 'Comment' => array('id', 'article_id', 'user_id'), - 'Attachment' => array('comment_id') - ); - $result = $TestModel->saveAll(array( + $record = array( 'Comment' => array( - 'id' => 5, - 'comment' => $expected['Comment']['comment'] .' some more', + 'user_id' => 1, + 'article_id' => 1, + 'comment' => '', ), 'Attachment' => array( - 'comment_id' => $expected['Attachment']['comment_id'], - 'attachment' => $expected['Attachment']['attachment'] .' some more' + 'attachment' => '' ) - ), array('fieldList' => $fieldList)); - $this->assertTrue($result); + ); + $result = $TestModel->saveAll($record, array('validate' => 'only')); + $this->assertFalse($result); - $result = $TestModel->find('first', array( - 'conditions' => array('Comment.id' => 5), - 'recursive' => 0 + $fieldList = array( + 'Comment' => array('id', 'article_id', 'user_id'), + 'Attachment' => array('comment_id') + ); + $result = $TestModel->saveAll($record, array( + 'fieldList' => $fieldList, 'validate' => 'only' )); - - $this->assertEquals($expected['Comment']['comment'], $result['Comment']['comment']); - $this->assertEquals($expected['Attachment']['attachment'], $result['Attachment']['attachment']); + $this->assertTrue($result); + $this->assertEmpty($TestModel->validationErrors); } }