Skip to content
Permalink
Browse files

Adding failing tests for ticket #3873

  • Loading branch information...
lorenzo committed Jul 5, 2014
1 parent c854e1f commit 9b20a2119f4ed7f4cd5fd843b01d39850d6d0678
Showing with 26 additions and 0 deletions.
  1. +26 −0 tests/TestCase/ORM/TableTest.php
@@ -2083,6 +2083,32 @@ public function testAfterValidate() {
$this->assertEquals(['Not good'], $entity->errors('username'));
}
/**
* Tests using a custom validation object when saving and saving associations
*
* @return void
*/
public function testSaveWithDifferentValidatorAndAssociations() {
$entity = new \Cake\ORM\Entity([
'title' => 'foo',
'body' => 'bar',
'author' => new \Cake\ORM\Entity([
'name' => 'Susan'
])
]);
$table = TableRegistry::get('articles');
$table->belongsTo('authors');
$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']));
$this->assertNotEmpty($entity->author->errors('thing'));
$this->assertSame($entity, $table->save($entity), 'default was not used');
}
/**
* Test magic findByXX method.
*

0 comments on commit 9b20a21

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