Exemple #1
0
 public function testAllowsPrependingValidatorsByName()
 {
     $this->_validator->addValidator(new ValidatorTrue())
                      ->prependByName('NotEmpty', array(), true);
     $this->assertFalse($this->_validator->isValid(''));
     $messages = $this->_validator->getMessages();
     $this->assertArrayHasKey('isEmpty', $messages);
 }
Exemple #2
0
 /**
  * Ensures that a validator may break the chain
  *
  * @return void
  */
 public function testBreakChainOnFailure()
 {
     $this->_validator->addValidator(new ValidatorFalse(), true)->addValidator(new ValidatorFalse());
     $this->assertFalse($this->_validator->isValid(null));
     $this->assertEquals(array('error' => 'validation failed'), $this->_validator->getMessages());
 }