/** * @group nnn1 */ public function testIsValid() { $element = new Element('test'); $validator = Validator::getValidatorInstance('Zend\\Validator\\StringLength', array('max' => 10)); $this->assertInstanceOf('\\Zend\\Validator\\StringLength', $validator); $element->addValidator($validator); $element->setValue('This is very long string'); $this->assertFalse($element->isValid()); $element = new Element('test'); $element->setAllowEmpty(false); $this->assertFalse($element->getAllowEmpty()); $this->assertFalse($element->isValid()); $factory = new Factory(); $element = $factory->create(array('type' => 'App\\Form\\Element', 'options' => array('view_path' => FIXTURES_PATH . '/Form/decorators/', 'multiple' => true, 'validators' => array('Zend\\Validator\\Digits')), 'attributes' => array('id' => 'id_name', 'name' => 'var_name', 'class' => 'input p_input', 'value' => '<some value "here">', 'label' => 'Some label name', 'label_class' => 'test'))); $element->setOptions(array('model_link' => array('Model\\TestModel'))); // True if empty value $this->assertTrue($element->setAllowEmpty(true)->isValid()); $this->assertTrue($element->setValue('34')->isValid()); $element = new Element('test'); $element->setValue('test'); $this->assertTrue($element->isValid()); $element->addValidator('Zend\\Validator\\StringLength', array('min' => 1, 'max' => 2)); $this->assertFalse($element->isValid()); $element->setModelLink('Model\\TestModel', 'test'); $this->assertFalse($element->isValid()); $element->setModelLink('Model\\TestModel'); $this->assertFalse($element->isValid()); }