@@ 3077-3109 (lines=33) @@ | ||
3074 | * |
|
3075 | * @return void |
|
3076 | */ |
|
3077 | public function testSaveAllHasOneValidation() { |
|
3078 | $model = new Comment(); |
|
3079 | $model->deleteAll(true); |
|
3080 | $this->assertEquals(array(), $model->find('all')); |
|
3081 | ||
3082 | $model->Attachment->deleteAll(true); |
|
3083 | $this->assertEquals(array(), $model->Attachment->find('all')); |
|
3084 | ||
3085 | $model->validate = array('comment' => 'notEmpty'); |
|
3086 | $model->Attachment->validate = array('attachment' => 'notEmpty'); |
|
3087 | $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); |
|
3088 | ||
3089 | $result = $model->saveAll( |
|
3090 | array( |
|
3091 | 'Comment' => array( |
|
3092 | 'comment' => '', |
|
3093 | 'article_id' => 1, |
|
3094 | 'user_id' => 1 |
|
3095 | ), |
|
3096 | 'Attachment' => array('attachment' => '') |
|
3097 | ), |
|
3098 | array('validate' => 'first') |
|
3099 | ); |
|
3100 | $this->assertEquals(false, $result); |
|
3101 | $expected = array( |
|
3102 | 'comment' => array('This field cannot be left blank'), |
|
3103 | 'Attachment' => array( |
|
3104 | 'attachment' => array('This field cannot be left blank') |
|
3105 | ) |
|
3106 | ); |
|
3107 | $this->assertEquals($expected, $model->validationErrors); |
|
3108 | $this->assertEquals($expected['Attachment'], $model->Attachment->validationErrors); |
|
3109 | } |
|
3110 | ||
3111 | /** |
|
3112 | * testSaveAllAtomic method |
|
@@ 5283-5318 (lines=36) @@ | ||
5280 | * |
|
5281 | * @return void |
|
5282 | */ |
|
5283 | public function testSaveAssociatedHasOneValidation() { |
|
5284 | $model = new Comment(); |
|
5285 | $model->deleteAll(true); |
|
5286 | $this->assertEquals(array(), $model->find('all')); |
|
5287 | ||
5288 | $model->Attachment->deleteAll(true); |
|
5289 | $this->assertEquals(array(), $model->Attachment->find('all')); |
|
5290 | ||
5291 | $model->validate = array('comment' => 'notEmpty'); |
|
5292 | $model->Attachment->validate = array('attachment' => 'notEmpty'); |
|
5293 | $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); |
|
5294 | ||
5295 | $result = $model->saveAssociated( |
|
5296 | array( |
|
5297 | 'Comment' => array( |
|
5298 | 'comment' => '', |
|
5299 | 'article_id' => 1, |
|
5300 | 'user_id' => 1 |
|
5301 | ), |
|
5302 | 'Attachment' => array('attachment' => '') |
|
5303 | ) |
|
5304 | ); |
|
5305 | $this->assertFalse($result); |
|
5306 | $expected = array( |
|
5307 | 'comment' => array( |
|
5308 | 'This field cannot be left blank' |
|
5309 | ), |
|
5310 | 'Attachment' => array( |
|
5311 | 'attachment' => array( |
|
5312 | 'This field cannot be left blank' |
|
5313 | ) |
|
5314 | ) |
|
5315 | ); |
|
5316 | $this->assertEquals($expected, $model->validationErrors); |
|
5317 | $this->assertEquals($expected['Attachment'], $model->Attachment->validationErrors); |
|
5318 | } |
|
5319 | ||
5320 | /** |
|
5321 | * testSaveAssociatedAtomic method |