示例#1
0
 /**
  * Check array notation for validators
  */
 public function testValidatorsGivenArrayKeysOnValidation()
 {
     $username = new Element('username');
     $username->addValidator('stringLength', true, array('min' => 5, 'max' => 20, 'ignore' => 'something'));
     $form = new Form(array('elements' => array($username)));
     $this->assertTrue($form->isValid(array('username' => 'abcde')));
 }
示例#2
0
 public function setupElement()
 {
     $element = new Element('foo');
     $element->addValidator('Alnum')->addValidator('Alpha')->setView($this->getView());
     $element->isValid('abc-123');
     $this->element = $element;
     $this->decorator->setElement($element);
 }
示例#3
0
 /**
  * @group ZF-2862
  */
 public function testBreakChainOnFailureFlagsForExistingValidatorsRemainSetWhenNotEmptyValidatorAutoInserted()
 {
     $username = new Element('username');
     $username->addValidator('stringLength', true, array(5, 20))->addValidator('regex', true, array('/^[a-zA-Z0-9_]*$/'))->addFilter('StringToLower')->setRequired(true);
     $form = new Form(array('elements' => array($username)));
     $form->isValid(array('username' => '#'));
     $validator = $username->getValidator('stringLength');
     $this->assertTrue($validator->zfBreakChainOnFailure);
     $validator = $username->getValidator('regex');
     $this->assertTrue($validator->zfBreakChainOnFailure);
 }