コード例 #1
0
 /**
  * Test isEmptyAllowed method
  *
  * @return void
  */
 public function testIsEmptyAllowed()
 {
     $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());
 }
コード例 #2
0
 /**
  * Test isEmptyAllowed method
  *
  * @return void
  */
 public function testIsEmptyAllowed()
 {
     $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' => 'notBlank', 'allowEmpty' => FALSE, 'on' => 'update');
     $Rule = new CakeValidationRule($def);
     $this->assertTrue($Rule->isEmptyAllowed());
     $Rule->isUpdate(TRUE);
     $this->assertFalse($Rule->isEmptyAllowed());
     $def = array('rule' => 'notBlank', 'allowEmpty' => FALSE, 'on' => 'create');
     $Rule = new CakeValidationRule($def);
     $this->assertFalse($Rule->isEmptyAllowed());
     $Rule->isUpdate(TRUE);
     $this->assertTrue($Rule->isEmptyAllowed());
 }