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->autoComplete("element", "", array('data' => array('test'))); $this->assertTrue($this->jquery->isEnabled()); $this->assertTrue($this->jquery->uiIsEnabled()); } public function testShouldAppendToJqueryHelper() { $element = $this->view->autoComplete("elem1", "Default", array('option' => 'true', 'data' => array('test')), array()); $jquery = $this->view->jQuery()->__toString(); $this->assertContains('autocomplete(', $jquery); $this->assertContains('"option":"true"', $jquery); } /** * @expectedException ZendX_JQuery_Exception */ public function testShouldAllowAutoCompleteOnlyWithDataOrUrlOption() { $element = $this->view->autoComplete("elem1"); } public function testShouldCreateInputField() { $element = $this->view->autoComplete("elem1", "Default", array('data' => array('Test'))); $this->assertEquals(array('$("#elem1").autocomplete({"data":["Test"]});'), $this->view->jQuery()->getOnLoadActions()); $this->assertContains("assertContains('id="elem1"', $element); $this->assertContains('value="Default"', $element); } } if (PHPUnit_MAIN_METHOD == 'ZendX_JQuery_View_AutoCompleteTest::main') { ZendX_JQuery_View_AutoCompleteTest::main(); }