mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 18:12:40 +00:00
Implemented new method isEmptyAllowed in CakeValidationRule
This commit is contained in:
parent
785cf8354c
commit
217bf85537
2 changed files with 38 additions and 0 deletions
|
@ -132,4 +132,33 @@ class CakeValidationRuleTest extends CakeTestCase {
|
|||
$Rule->isUpdate(true);
|
||||
$this->assertTrue($Rule->isRequired());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test isEmptyAllowed method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsEmplyAllowed() {
|
||||
$def = array('rule' => 'aRule', 'allowEmpty' => true);
|
||||
$Rule = new CakeValidationRule($def);
|
||||
$this->assertTrue($Rule->isEmptyAllowed());
|
||||
|
||||
$def = array('rule' => 'aRule', 'allowEmpty' => false);
|
||||
$Rule = new CakeValidationRule($def);
|
||||
$this->assertFalse($Rule->isEmptyAllowed());
|
||||
|
||||
$def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'update');
|
||||
$Rule = new CakeValidationRule($def);
|
||||
$this->assertTrue($Rule->isEmptyAllowed());
|
||||
|
||||
$Rule->isUpdate(true);
|
||||
$this->assertFalse($Rule->isEmptyAllowed());
|
||||
|
||||
$def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'create');
|
||||
$Rule = new CakeValidationRule($def);
|
||||
$this->assertFalse($Rule->isEmptyAllowed());
|
||||
|
||||
$Rule->isUpdate(true);
|
||||
$this->assertTrue($Rule->isEmptyAllowed());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue