Пример #1
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testMessages()
 {
     $element = new Element('some_field');
     $element->setModelLink('Model\\TestModel');
     $element->setValue('Значение которое не пройдет валидацию');
     $this->assertFalse($element->isValid());
     $this->assertEquals(array(array('stringLengthTooLong' => 'The input is more than 10 characters long')), $element->getMessages());
     $element->removeModelLink()->clearMessages()->addValidator('Zend\\Validator\\StringLength', array('min' => 1, 'max' => 5))->isValid();
     $this->assertEquals(array(array('stringLengthTooLong' => 'The input is more than 5 characters long')), $element->getMessages());
     $this->assertEquals(array('stringLengthTooLong' => 'The input is more than 5 characters long'), $element->getMessages(0));
     $this->assertEquals(array(), $element->getMessages(1));
     $element->setMessages(new \stdClass());
 }