|
@@ 4084-4117 (lines=34) @@
|
| 4081 |
|
* |
| 4082 |
|
* @return void |
| 4083 |
|
*/ |
| 4084 |
|
public function testSaveAllHasManyValidation() { |
| 4085 |
|
$this->loadFixtures('Article', 'Comment'); |
| 4086 |
|
$TestModel = new Article(); |
| 4087 |
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); |
| 4088 |
|
$TestModel->Comment->validate = array('comment' => 'notEmpty'); |
| 4089 |
|
|
| 4090 |
|
$result = $TestModel->saveAll(array( |
| 4091 |
|
'Article' => array('id' => 2), |
| 4092 |
|
'Comment' => array( |
| 4093 |
|
array('comment' => '', 'published' => 'Y', 'user_id' => 1), |
| 4094 |
|
) |
| 4095 |
|
), array('validate' => true)); |
| 4096 |
|
$this->assertFalse($result); |
| 4097 |
|
|
| 4098 |
|
$expected = array('Comment' => array( |
| 4099 |
|
array('comment' => array('This field cannot be left blank')) |
| 4100 |
|
)); |
| 4101 |
|
$this->assertEquals($expected, $TestModel->validationErrors); |
| 4102 |
|
$expected = array( |
| 4103 |
|
array('comment' => array('This field cannot be left blank')) |
| 4104 |
|
); |
| 4105 |
|
$this->assertEquals($expected, $TestModel->Comment->validationErrors); |
| 4106 |
|
|
| 4107 |
|
$result = $TestModel->saveAll(array( |
| 4108 |
|
'Article' => array('id' => 2), |
| 4109 |
|
'Comment' => array( |
| 4110 |
|
array( |
| 4111 |
|
'comment' => '', |
| 4112 |
|
'published' => 'Y', |
| 4113 |
|
'user_id' => 1 |
| 4114 |
|
)) |
| 4115 |
|
), array('validate' => 'first')); |
| 4116 |
|
$this->assertFalse($result); |
| 4117 |
|
} |
| 4118 |
|
|
| 4119 |
|
/** |
| 4120 |
|
* test saveAll with transactions and ensure there is no missing rollback. |
|
@@ 5517-5550 (lines=34) @@
|
| 5514 |
|
* |
| 5515 |
|
* @return void |
| 5516 |
|
*/ |
| 5517 |
|
public function testSaveAssociatedHasManyValidation() { |
| 5518 |
|
$this->loadFixtures('Article', 'Comment'); |
| 5519 |
|
$TestModel = new Article(); |
| 5520 |
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); |
| 5521 |
|
$TestModel->Comment->validate = array('comment' => 'notEmpty'); |
| 5522 |
|
|
| 5523 |
|
$result = $TestModel->saveAssociated(array( |
| 5524 |
|
'Article' => array('id' => 2), |
| 5525 |
|
'Comment' => array( |
| 5526 |
|
array('comment' => '', 'published' => 'Y', 'user_id' => 1), |
| 5527 |
|
) |
| 5528 |
|
), array('validate' => true)); |
| 5529 |
|
$this->assertFalse($result); |
| 5530 |
|
|
| 5531 |
|
$expected = array('Comment' => array( |
| 5532 |
|
array('comment' => array('This field cannot be left blank')) |
| 5533 |
|
)); |
| 5534 |
|
$this->assertEquals($expected, $TestModel->validationErrors); |
| 5535 |
|
$expected = array( |
| 5536 |
|
array('comment' => array('This field cannot be left blank')) |
| 5537 |
|
); |
| 5538 |
|
$this->assertEquals($expected, $TestModel->Comment->validationErrors); |
| 5539 |
|
|
| 5540 |
|
$result = $TestModel->saveAssociated(array( |
| 5541 |
|
'Article' => array('id' => 2), |
| 5542 |
|
'Comment' => array( |
| 5543 |
|
array( |
| 5544 |
|
'comment' => '', |
| 5545 |
|
'published' => 'Y', |
| 5546 |
|
'user_id' => 1 |
| 5547 |
|
)) |
| 5548 |
|
), array('validate' => 'first')); |
| 5549 |
|
$this->assertFalse($result); |
| 5550 |
|
} |
| 5551 |
|
|
| 5552 |
|
/** |
| 5553 |
|
* test saveMany with transactions and ensure there is no missing rollback. |