Skip to content

Commit

Permalink
Improving validation tests in marshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 19, 2014
1 parent 7fc122f commit 373a2bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -1533,21 +1533,25 @@ public function testValidateWithAssociationsAndCustomValidator() {
$validator2 = (new Validator)->requirePresence('thing');
$this->articles->Users->validator('customThing', $validator2);

$this->articles->Comments->validator('default', $validator2);

$entity = (new Marshaller($this->articles))->one($data, [
'validate' => 'custom',
'associated' => ['Users']
'associated' => ['Users', 'Comments']
]);
$this->assertNotEmpty($entity->errors('body'), 'custom was not used');
$this->assertNull($entity->body);
$this->assertEmpty($entity->user->errors('thing'));
$this->assertNotEmpty($entity->comments[0]->errors('thing'));

$entity = (new Marshaller($this->articles))->one($data, [
'validate' => 'custom',
'associated' => ['Users' => ['validate' => 'customThing']]
'associated' => ['Users' => ['validate' => 'customThing'], 'Comments']
]);
$this->assertNotEmpty($entity->errors('body'));
$this->assertNull($entity->body);
$this->assertNotEmpty($entity->user->errors('thing'), 'customThing was not used');
$this->assertNotEmpty($entity->comments[0]->errors('thing'));
}

}

0 comments on commit 373a2bf

Please sign in to comment.