Skip to content

Commit

Permalink
Added tests for PR #7646
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 4, 2015
1 parent db63617 commit 94039ba
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/TestCase/Validation/ValidatorTest.php
Expand Up @@ -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.