Просмотр исходного кода

Merge r25206 to 1.12 release branch

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25207 44c647ce-9c0f-0410-b52a-842ac1e357ba
frosch 13 лет назад
Родитель
Сommit
7b0a8f37bb
2 измененных файлов с 33 добавлено и 3 удалено
  1. 10 0
      library/Zend/View/Helper/FormErrors.php
  2. 23 3
      tests/Zend/View/Helper/FormErrorsTest.php

+ 10 - 0
library/Zend/View/Helper/FormErrors.php

@@ -69,6 +69,16 @@ class Zend_View_Helper_FormErrors extends Zend_View_Helper_FormElement
             $options['class'] = 'errors';
         }
 
+        if (isset($options['elementStart'])) {
+            $this->setElementStart($options['elementStart']);
+        }
+        if (isset($options['elementEnd'])) {
+            $this->setElementEnd($options['elementEnd']);
+        }
+        if (isset($options['elementSeparator'])) {
+            $this->setElementSeparator($options['elementSeparator']);
+        }
+
         $start = $this->getElementStart();
         if (strstr($start, '%s')) {
             $attribs = $this->_htmlAttribs($options);

+ 23 - 3
tests/Zend/View/Helper/FormErrorsTest.php

@@ -166,9 +166,29 @@ class Zend_View_Helper_FormErrorsTest extends PHPUnit_Framework_TestCase
      */
     public function testCanSetClassAttribute()
     {
-        $options = array('class' => 'custom-class');
-        $acutallHtml = $this->helper->formErrors(array(), $options);
-        $this->assertEquals('<ul class="custom-class"><li></li></ul>', $acutallHtml);
+        $options    = array('class' => 'custom-class');
+        $actualHtml = $this->helper->formErrors(array(), $options);
+        $this->assertEquals(
+            '<ul class="custom-class"><li></li></ul>',
+            $actualHtml
+        );
+    }
+
+    /**
+     * @group ZF-5962
+     */
+    public function testCanSetElementStringsPerOptions()
+    {
+        $actual = $this->helper->formErrors(
+            array('foo', 'bar', 'baz'),
+            array(
+                 'elementStart'     => '<p>',
+                 'elementEnd'       => '</p>',
+                 'elementSeparator' => '<br>',
+            )
+        );
+
+        $this->assertEquals('<p>foo<br>bar<br>baz</p>', $actual);
     }
 }