view = $this->getView(); } /** * 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; } /** * @expectedException Zend_Dojo_View_Exception */ public function testHelperShouldRaiseExceptionIfNoDojoTypePassed() { $this->view->customDijit('foo'); } public function testHelperInDeclarativeModeShouldGenerateDivWithPassedDojoType() { $content = $this->view->customDijit('foo', 'content', array('dojoType' => 'custom.Dijit')); $this->assertContains('dojoType="custom.Dijit"', $content); } public function testHelperInDeclarativeModeShouldRegisterDojoTypeAsModule() { $content = $this->view->customDijit('foo', 'content', array('dojoType' => 'custom.Dijit')); $dojo = $this->view->dojo(); $modules = $dojo->getModules(); $this->assertContains('custom.Dijit', $modules); } public function testHelperInProgrammaticModeShouldRegisterDojoTypeAsModule() { Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); $content = $this->view->customDijit('foo', 'content', array('dojoType' => 'custom.Dijit')); $dojo = $this->view->dojo(); $modules = $dojo->getModules(); $this->assertContains('custom.Dijit', $modules); } public function testHelperInProgrammaticModeShouldGenerateDivWithoutPassedDojoType() { Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); $content = $this->view->customDijit('foo', 'content', array('dojoType' => 'custom.Dijit')); $this->assertNotContains('dojoType="custom.Dijit"', $content); } public function testHelperShouldAllowCapturingContent() { $this->view->customDijit()->captureStart('foo', array('dojoType' => 'custom.Dijit')); echo "Captured content started\n"; $content = $this->view->customDijit()->captureEnd('foo'); $this->assertContains(">Captured content started\n<", $content); } public function testUsesDefaultDojoTypeWhenPresent() { $helper = new Zend_Dojo_View_Helper_CustomDijitTest_FooContentPane(); $helper->setView($this->view); $content = $helper->fooContentPane('foo'); $this->assertContains('dojoType="foo.ContentPane"', $content); } public function testCapturingUsesDefaultDojoTypeWhenPresent() { $helper = new Zend_Dojo_View_Helper_CustomDijitTest_FooContentPane(); $helper->setView($this->view); $helper->fooContentPane()->captureStart('foo'); echo "Captured content started\n"; $content = $helper->fooContentPane()->captureEnd('foo'); $this->assertContains(">Captured content started\n<", $content); $this->assertContains('dojoType="foo.ContentPane"', $content); } /** * @group ZF-7890 */ public function testHelperShouldAllowSpecifyingRootNode() { $content = $this->view->customDijit('foo', 'content', array( 'dojoType' => 'custom.Dijit', 'rootNode' => 'select', )); $this->assertContains('customDijit($id, $value, $params, $attribs); } } // Call Zend_Dojo_View_Helper_CustomDijitTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_CustomDijitTest::main") { Zend_Dojo_View_Helper_CustomDijitTest::main(); }