Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unit Test for the hasErrors() method.
  • Loading branch information
JoshuaLuckers committed Jul 6, 2018
1 parent 3dea5f9 commit 6e70be9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -1281,6 +1281,42 @@ public function testErrorsDeep()
$this->assertEquals($expected, $author->getErrors());
}

/**
* Tests that check if hasErrors() works
*
* @return void
*/
public function testHasErrors()
{
$entity = new Entity();
$hasErrors = $entity->hasErrors();
$this->assertFalse($hasErrors);

$nestedEntity = new Entity();
$entity->set([
'nested' => $nestedEntity,
]);
$hasErrors = $entity->hasErrors();
$this->assertFalse($hasErrors);

$nestedEntity->setError('description', 'oops');
$hasErrors = $entity->hasErrors();
$this->assertTrue($hasErrors);

$hasErrors = $entity->hasErrors(false);
$this->assertFalse($hasErrors);

$entity->clean();
$hasErrors = $entity->hasErrors();
$this->assertTrue($hasErrors);
$hasErrors = $entity->hasErrors(false);
$this->assertFalse($hasErrors);

$nestedEntity->clean();
$hasErrors = $entity->hasErrors();
$this->assertFalse($hasErrors);
}

/**
* Test that errors can be read with a path.
*
Expand Down

0 comments on commit 6e70be9

Please sign in to comment.