view = new Zend_View(); $this->helper = new Zend_View_Helper_Form(); $this->helper->setView($this->view); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } public function testFormWithSaneInput() { $form = $this->helper->form('foo', array('action' => '/foo', 'method' => 'get')); $this->assertRegexp('/]*(id="foo")/', $form); $this->assertRegexp('/]*(action="\/foo")/', $form); $this->assertRegexp('/]*(method="get")/', $form); } public function testFormWithInputNeedingEscapesUsesViewEscaping() { $form = $this->helper->form('<&foo'); $this->assertContains($this->view->escape('<&foo'), $form); } public function testPassingIdAsAttributeShouldRenderIdAttribAndNotName() { $form = $this->helper->form('foo', array('action' => '/foo', 'method' => 'get', 'id' => 'bar')); $this->assertRegexp('/]*(id="bar")/', $form); $this->assertNotRegexp('/]*(name="foo")/', $form); } /** * @see ZF-3832 */ public function testEmptyIdShouldNotRenderIdAttribute() { $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get')); $this->assertNotRegexp('/]*(id="")/', $form); $form = $this->helper->form('', array('action' => '/foo', 'method' => 'get', 'id' => null)); $this->assertNotRegexp('/]*(id="")/', $form); } } // Call Zend_View_Helper_FormTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTest::main") { Zend_View_Helper_FormTest::main(); }