diff --git a/tests/TestCase/Validation/ValidatorTest.php b/tests/TestCase/Validation/ValidatorTest.php index 1df83f4da37..0055552691e 100644 --- a/tests/TestCase/Validation/ValidatorTest.php +++ b/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. *