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

ZF-10791
Zend_Form
Test suite update which was accidentally omitted from r23945


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23947 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 лет назад
Родитель
Сommit
5749fecd1b
1 измененных файлов с 66 добавлено и 0 удалено
  1. 66 0
      tests/Zend/View/Helper/FormTest.php

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

@@ -108,6 +108,72 @@ class Zend_View_Helper_FormTest extends PHPUnit_Framework_TestCase
         $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get', 'id' => null));
         $this->assertNotRegexp('/<form[^>]*(id="")/', $form);
     }
+    
+    /**
+     * @group ZF-10791
+     */
+    public function testPassingNameAsAttributeShouldOverrideFormName()
+    {
+        $form = $this->helper->form('OrigName', array('action' => '/foo', 'method' => 'get', 'name' => 'SomeNameAttr'));
+        $this->assertNotRegexp('/<form[^>]*(name="OrigName")/', $form);
+        $this->assertRegexp('/<form[^>]*(name="SomeNameAttr")/', $form);
+    }
+    
+    /**
+     * @group ZF-10791
+     */
+    public function testNotSpecifyingFormNameShouldNotRenderNameAttrib()
+    {
+        $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get'));
+        $this->assertNotRegexp('/<form[^>]*(name=".*")/', $form);
+    }
+    
+    /**
+     * @group ZF-10791
+     */
+    public function testSpecifyingFormNameShouldRenderNameAttrib()
+    {
+        $form = $this->helper->form('FormName', array('action' => '/foo', 'method' => 'get'));
+        $this->assertRegexp('/<form[^>]*(name="FormName")/', $form);
+    }
+    
+    /**
+     * @group ZF-10791
+     */
+    public function testPassingEmptyNameAttributeToUnnamedFormShouldNotRenderNameAttrib()
+    {
+        $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get', 'name' => NULL));
+        $this->assertNotRegexp('/<form[^>]*(name=".*")/', $form);
+    }
+    
+    /**
+     * @group ZF-10791
+     */
+    public function testPassingEmptyNameAttributeToNamedFormShouldNotOverrideNameAttrib()
+    {
+        $form = $this->helper->form('RealName', array('action' => '/foo', 'method' => 'get', 'name' => NULL));
+        $this->assertRegexp('/<form[^>]*(name="RealName")/', $form);
+    }
+        
+    /**
+     * @group ZF-10791
+     */
+    public function testNameAttributeShouldBeOmittedWhenUsingXhtml1Strict()
+    {
+        $this->view->doctype('XHTML1_STRICT');
+        $form = $this->helper->form('FormName', array('action' => '/foo', 'method' => 'get'));
+        $this->assertNotRegexp('/<form[^>]*(name="FormName")/', $form);
+    }
+        
+    /**
+     * @group ZF-10791
+     */
+    public function testNameAttributeShouldBeOmittedWhenUsingXhtml11()
+    {
+        $this->view->doctype('XHTML11');
+        $form = $this->helper->form('FormName', array('action' => '/foo', 'method' => 'get'));
+        $this->assertNotRegexp('/<form[^>]*(name="FormName")/', $form);
+    }    
 }
 
 // Call Zend_View_Helper_FormTest::main() if this source file is executed directly.