Skip to content
Permalink
Browse files

Add tests for Entity::errors() being able to read data with a path.

Refs #3807
  • Loading branch information...
markstory committed Jul 9, 2014
1 parent af7666c commit 3d22390739bdaadd09a19fb22512295de8be8305
Showing with 27 additions and 0 deletions.
  1. +27 −0 tests/TestCase/ORM/EntityTest.php
@@ -824,6 +824,33 @@ public function testErrorsDeep() {
$this->assertEquals($expected, $entity->errors('multiple'));
}
/**
* Test that errors can be read with a path.
*
* @return void
*/
public function testErrorPathReading() {
$assoc = new Entity;
$entity= new Entity([
'field' => 'value',
'one' => $assoc,
'many' => [$assoc]
]);
$entity->errors('wrong', 'Bad stuff');
$assoc->errors('nope', 'Terrible things');
$this->assertEquals('Bad stuff', $entity->errors('wrong'));
$this->assertEquals('Terrible things', $entity->errors('many.0.nope'));
$this->assertEquals('Terrible things', $entity->errors('one.nope'));
$this->assertEquals(['nope' => 'Terrible things'], $entity->errors('one'));
$this->assertEquals(['nope' => 'Terrible things'], $entity->errors('many.0'));
$this->assertEquals([], $entity->errors('many.0.mistake'));
$this->assertEquals([], $entity->errors('one.mistake'));
$this->assertEquals([], $entity->errors('one.1.mistake'));
$this->assertEquals([], $entity->errors('many.1.nope'));
}
/**
* Tests that changing the value of a property will remove errors
* stored for it

0 comments on commit 3d22390

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