Skip to content
Permalink
Browse files

Added fix for #3873

  • Loading branch information...
lorenzo committed Jul 27, 2014
1 parent d4fabc9 commit 0d66b61e5faa094f53d797a2810d889c2f782421
Showing with 14 additions and 2 deletions.
  1. +1 −1 src/ORM/Table.php
  2. +13 −1 tests/TestCase/ORM/TableTest.php
@@ -1199,7 +1199,7 @@ protected function _processSave($entity, $options) {
$this,
$entity,
$options['associated'],
$options->getArrayCopy()
['validate' => (bool)$validate] + $options->getArrayCopy()
);
if ($success || !$options['atomic']) {
$entity->clean();
@@ -2136,17 +2136,29 @@ public function testSaveWithDifferentValidatorAndAssociations() {
'body' => 'bar',
'author' => new \Cake\ORM\Entity([
'name' => 'Susan'
])
]),
'articles_tags' => [
new \Cake\ORM\Entity([
'tag_id' => 100
])
]
]);
$table = TableRegistry::get('articles');
$table->belongsTo('authors');
$table->hasMany('ArticlesTags');
$validator = (new Validator)->validatePresence('body');
$table->validator('custom', $validator);
$validator2 = (new Validator)->validatePresence('thing');
$table->authors->validator('default', $validator2);
$this->assertFalse($table->save($entity, ['validate' => 'custom']), 'default was not used');
$this->assertNotEmpty($entity->author->errors('thing'));
$validator3 = (new Validator)->validatePresence('thing');
$table->ArticlesTags->validator('default', $validator2);
unset($entity->author);
$this->assertFalse($table->save($entity, ['validate' => 'custom']), 'default was not used');
$this->assertNotEmpty($entity->articles_tags[0]->errors('thing'));
}
/**

0 comments on commit 0d66b61

Please sign in to comment.
You can’t perform that action at this time.