|
|
@@ -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.
|