view = $this->getView(); $this->helper = new Zend_Dojo_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. * * @return void */ public function tearDown() { } public function getView() { require_once 'Zend/View.php'; $view = new Zend_View(); $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); return $view; } public function getForm() { return $this->helper->form('myForm', array('action' => '/foo'), ''); } public function testShouldAllowDeclarativeDijitCreation() { $html = $this->getForm(); $this->assertRegexp('/]*(dojoType="dijit.form.Form")/', $html, $html); } public function testShouldAllowProgrammaticDijitCreation() { Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); $html = $this->getForm(); $this->assertNotRegexp('/]*(dojoType="dijit.form.Form")/', $html); $this->assertNotNull($this->view->dojo()->getDijit('myForm')); } public function testOnlyIdShouldBeNecessary() { Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); $html = $this->view->form('foo'); $this->assertRegexp('/]*(dojoType="dijit.form.Form")/', $html, $html); $this->assertRegexp('/]*(id="foo")/', $html, $html); } public function testShouldNotRenderIdAsHtmlIdWhenIdPassedAsAttrib() { $html = $this->helper->form('foo', array('id' => 'bar')); $this->assertRegexp('/]*(id="bar")/', $html); } public function testShouldNotRenderClosingTagIfContentIsFalse() { $html = $this->helper->form('foo'); $this->assertNotRegexp('/<\/form>/', $html); } } // Call Zend_Dojo_View_Helper_FormTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_FormTest::main") { Zend_Dojo_View_Helper_FormTest::main(); }