Browse Source

ZF-11747: Zend_View_Helper_Form omits closing tag when no content is passed

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24477 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan 14 years ago
parent
commit
28e7817ab1
2 changed files with 15 additions and 2 deletions
  1. 3 2
      library/Zend/View/Helper/Form.php
  2. 12 0
      tests/Zend/View/Helper/FormTest.php

+ 3 - 2
library/Zend/View/Helper/Form.php

@@ -73,10 +73,11 @@ class Zend_View_Helper_Form extends Zend_View_Helper_FormElement
                . '>';
 
         if (false !== $content) {
-            $xhtml .= $content
-                   .  '</form>';
+            $xhtml .= $content;
         }
 
+        $xhtml .= '</form>';
+
         return $xhtml;
     }
 }

+ 12 - 0
tests/Zend/View/Helper/FormTest.php

@@ -167,6 +167,18 @@ class Zend_View_Helper_FormTest extends PHPUnit_Framework_TestCase
         $form = $this->helper->form('FormName', array('action' => '/foo', 'method' => 'get'));
         $this->assertNotRegexp('/<form[^>]*(name="FormName")/', $form);
     }    
+
+    /**
+     * @group ZF-11747
+     */
+    public function testClosingTagIsPrintedWhenContentIsOmitted()
+    {
+        $form = $this->helper->form('FormName');
+        // Check that opening tag was printed
+        $this->assertContains('<form', $form);
+        // Check that closing tag was printed
+        $this->assertContains('</form>', $form);
+    }    
 }
 
 // Call Zend_View_Helper_FormTest::main() if this source file is executed directly.