Skip to content
Permalink
Browse files

Added tests for PR #7646

  • Loading branch information...
lorenzo committed Nov 4, 2015
1 parent db63617 commit 94039ba5c11dffa1a7bd3f7d89a1c52d7bebc9a3
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/TestCase/Validation/ValidatorTest.php
@@ -1015,4 +1015,36 @@ public function testDebugInfo()
];
$this->assertEquals($expected, $result);
}
/**
* Tests that the 'create' and 'update' modes are preserved when using
* nested validators
*
* @return void
*/
public function testNestedValidatorCreate()
{
$validator = new Validator();
$inner = new Validator();
$inner->add('username', 'email', ['rule' => 'email', 'on' => 'create']);
$validator->addNested('user', $inner);
$this->assertNotEmpty($validator->errors(['user' => ['username' => 'example']], true));
$this->assertEmpty($validator->errors(['user' => ['username' => 'a']], false));
}
/**
* Tests that the 'create' and 'update' modes are preserved when using
* nested validators
*
* @return void
*/
public function testNestedManyValidatorCreate()
{
$validator = new Validator();
$inner = new Validator();
$inner->add('username', 'email', ['rule' => 'email', 'on' => 'create']);
$validator->addNestedMany('user', $inner);
$this->assertNotEmpty($validator->errors(['user' => [['username' => 'example']]], true));
$this->assertEmpty($validator->errors(['user' => [['username' => 'a']]], false));
}
}

0 comments on commit 94039ba

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