Skip to content
Permalink
Browse files

Added a test case for errors when validation is only for create

  • Loading branch information...
davidyell committed May 4, 2017
1 parent c0219c8 commit b9e9cd34147e5418ad975e765de6e8a2dba6223d
Showing with 22 additions and 0 deletions.
  1. +22 −0 tests/TestCase/Validation/ValidatorTest.php
@@ -297,6 +297,28 @@ public function testErrorsWithPresenceRequired()
$this->assertEmpty($validator->errors(['foo' => 'bar']));
}
/**
* Test that validation on a certain condition generate errors
*
* @return void
*/
public function testErrorsWithPresenceRequiredOnCreate()
{
$validator = new Validator;
$validator->requirePresence('id', 'update');
$validator->allowEmpty('id', 'create');
$validator->requirePresence('title');
$data = [
'title' => 'Example title'
];
$expected = [];
$result = $validator->errors($data);
$this->assertEquals($expected, $result);
}
/**
* Test that errors() can work with nested data.
*

0 comments on commit b9e9cd3

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