view = $this->getView(); $this->jquery = new ZendX_JQuery_View_Helper_JQuery_Container(); $this->jquery->setView($this->view); Zend_Registry::set('ZendX_JQuery_View_Helper_JQuery', $this->jquery); } public function tearDown() { ZendX_JQuery_View_Helper_JQuery::disableNoConflictMode(); } public function getView() { require_once 'Zend/View.php'; $view = new Zend_View(); $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper'); return $view; } public function testCallingInViewEnablesJQueryHelper() { $element = $this->view->dialogContainer("element", ""); $this->assertTrue($this->jquery->isEnabled()); $this->assertTrue($this->jquery->uiIsEnabled()); } public function testShouldAppendToJqueryHelper() { $element = $this->view->dialogContainer("elem1", "", array("option" => "true")); $jquery = $this->jquery->__toString(); $this->assertContains('dialog(', $jquery); $this->assertContains('"option":"true"', $jquery); } public function testShouldCreateDivContainer() { $element = $this->view->dialogContainer("elem1", "", array(), array()); $this->assertEquals(array('$("#elem1").dialog({});'), $this->jquery->getOnLoadActions()); $this->assertContains("assertContains('id="elem1"', $element); $this->assertContains("", $element); } /** * @group ZF-4685 */ public function testUsingJsonExprForResizeShouldBeValidJsCallbackRegression() { $params = array( "resize" => new Zend_Json_Expr("doMyThingAtResize"), ); $this->view->dialogContainer("dialog1", "Some text", $params); $actions = $this->jquery->getOnLoadActions(); $this->assertEquals(array('$("#dialog1").dialog({"resize":doMyThingAtResize});'), $actions); } } if (PHPUnit_MAIN_METHOD == 'ZendX_JQuery_View_DialogContainerTest::main') { ZendX_JQuery_View_DialogContainerTest::main(); }