Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a test case for errors when validation is only for create
  • Loading branch information
David Yell committed May 4, 2017
1 parent c0219c8 commit b9e9cd3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/TestCase/Validation/ValidatorTest.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit b9e9cd3

Please sign in to comment.