public function testRendersNestedMessageSetsAsAFlatList() { $messages = array(array('First validator message'), array('Second validator first message', 'Second validator second message')); $element = new Element('foo'); $element->setMessages($messages); $markup = $this->helper->render($element, array('class' => 'error')); $this->assertRegexp('#<ul class="error">\\s*<li>First validator message</li>\\s*<li>Second validator first message</li>\\s*<li>Second validator second message</li>\\s*</ul>#s', $markup); }
public function testRendersOnErrorAsEspected() { $element = new Element('testElement'); $element->setAttribute('value', 'Initial Content'); $element->setMessages(array('testElement' => 'no valid')); $markup = $this->helper->render($element); $this->assertContains('error', $markup); }
public function testRendersErrorMessagesUsingSpans() { $messages = $this->getMessageList(); $element = new Element('foo'); $element->setMessages($messages); $markup = $this->helper->render($element); $this->assertRegexp('#<span class="help-inline">First error message</span>\\s*<span class="help-inline">Second error message</span>#s', $markup); }
public function testPassingElementWithErrorsAddsErrorClass() { $element = new Element('test'); $element->setMessages(array('FAIL')); $markup = $this->helper->openTag($element); $this->assertEquals(1, preg_match('/class="(.*)"/', $markup, $matches)); $classes = explode(' ', $matches[1]); $this->assertContains('error', $classes); $this->assertContains('control-group', $classes); }
public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors() { $element = new Element('foo'); $element->setMessages(array('Error message')); $element->setAttribute('class', 'foo bar'); $markup = $this->helper->setInputErrorClass('custom-error-class')->render($element); $this->assertRegexp('/<input name="foo" class="foo bar custom-error-class" type="text" [^\\/>]*\\/?>/', $markup); }
public function testSetMessagesWrongInputRaisesException() { $element = new Element('foo'); $this->setExpectedException('Zend\\Form\\Exception\\InvalidArgumentException'); $element->setMessages(null); }
/** * @inheritdoc */ public function setMessages($messages) { return $this->element->setMessages($messages); }
public function testCanRenderErrors() { $element = new Element('foo'); $element->setMessages(array('First error message', 'Second error message', 'Third error message')); $markup = $this->helper->render($element); $this->assertRegexp('#<ul>\\s*<li>First error message</li>\\s*<li>Second error message</li>\\s*<li>Third error message</li>\\s*</ul>#s', $markup); }