From e4cc18c0e7201b987d8d0fb5eadda7e286daa2f6 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 24 Dec 2011 01:18:07 +0530 Subject: [PATCH] Changing test case to make it pass on Sqlite --- lib/Cake/Test/Case/Model/ModelWriteTest.php | 41 ++++++++++----------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 835de0a71..7b58af7b6 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -5641,34 +5641,31 @@ class ModelWriteTest extends BaseModelTest { $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'); + + $record = array( + 'Comment' => array( + 'user_id' => 1, + 'article_id' => 1, + 'comment' => '', + ), + 'Attachment' => array( + 'attachment' => '' + ) + ); + $result = $TestModel->saveAll($record, array('validate' => 'only')); + $this->assertFalse($result); $fieldList = array( 'Comment' => array('id', 'article_id', 'user_id'), 'Attachment' => array('comment_id') ); - $result = $TestModel->saveAll(array( - 'Comment' => array( - 'id' => 5, - 'comment' => $expected['Comment']['comment'] .' some more', - ), - 'Attachment' => array( - 'comment_id' => $expected['Attachment']['comment_id'], - 'attachment' => $expected['Attachment']['attachment'] .' some more' - ) - ), array('fieldList' => $fieldList)); - $this->assertTrue($result); - - $result = $TestModel->find('first', array( - 'conditions' => array('Comment.id' => 5), - 'recursive' => 0 + $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); } }