mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding new test case for ModelValidator
This commit is contained in:
parent
2a90baae0c
commit
5ba5f906e6
1 changed files with 20 additions and 1 deletions
|
@ -2086,5 +2086,24 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$this->assertEquals('foo', $model->field('title', array('body' => 'a test')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Testing you can dynamically add rules to a field, added this to dispel doubts
|
||||
* after a presentation made to show off this new feature
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function testDynamicValidationRuleBuilding() {
|
||||
$model = new Article;
|
||||
$validator = $model->validator();
|
||||
$validator->add('body', 'isSpecial', array('rule' => 'special'));
|
||||
$rules = $validator['body']->getRules();
|
||||
$this->assertCount(2, $rules);
|
||||
$this->assertEquals('special', $rules['isSpecial']->rule);
|
||||
$validator['body']->setRule('isAwesome', array('rule' => 'awesome'));
|
||||
$rules = $validator['body']->getRules();
|
||||
$this->assertCount(3, $rules);
|
||||
$this->assertEquals('awesome', $rules['isAwesome']->rule);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue