view = $this->getView(); $this->helper = new Zend_Dojo_View_Helper_VerticalSlider(); $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 getElement() { return $this->helper->verticalSlider( 'elementId', '', array( 'minimum' => -10, 'maximum' => 10, 'discreteValues' => 11, 'topDecoration' => array( 'labels' => array( ' ', '20%', '40%', '60%', '80%', ' ', ), 'attribs' => array( 'container' => array( 'style' => 'height:1.2em; font-size=75%;color:gray;', ), 'labels' => array( 'style' => 'height:1em; font-size=75%;color:gray;', ), ), 'dijit' => 'VerticalRuleLabels', ), 'bottomDecoration' => array( 'labels' => array( '0%', '50%', '100%', ), 'attribs' => array( 'labels' => array( 'style' => 'height:1em; font-size=75%;color:gray;', ), ), ), 'leftDecoration' => array( 'labels' => array( ' ', '20%', '40%', '60%', '80%', ' ', ), 'attribs' => array( 'container' => array( 'style' => 'height:1.2em; font-size=75%;color:gray;', ), 'labels' => array( 'style' => 'height:1em; font-size=75%;color:gray;', ), ), 'dijit' => 'VerticalRuleLabels', ), 'rightDecoration' => array( 'labels' => array( '0%', '50%', '100%', ), 'attribs' => array( 'labels' => array( 'style' => 'height:1em; font-size=75%;color:gray;', ), ), ), ), array() ); } public function testShouldAllowDeclarativeDijitCreation() { $html = $this->getElement(); $this->assertRegexp('/]*(dojoType="dijit.form.VerticalSlider")/', $html, $html); } public function testShouldAllowProgrammaticDijitCreation() { Zend_Dojo_View_Helper_Dojo::setUseProgrammatic(); $html = $this->getElement(); $this->assertNotRegexp('/]*(dojoType="dijit.form.VerticalSlider")/', $html); $this->assertNotNull($this->view->dojo()->getDijit('elementId-slider')); } public function testShouldCreateOnChangeAttributeByDefault() { $html = $this->getElement(); $this->assertContains('onChange="dojo.byId(\'elementId\').value = arguments[0];"', $html, $html); } public function testShouldCreateHiddenElementWithValue() { $html = $this->getElement(); if (!preg_match('/(]*(type="hidden")[^>]*>)/', $html, $m)) { $this->fail('No hidden element found'); } $this->assertContains('id="elementId"', $m[1]); $this->assertContains('value="', $m[1]); } public function testShouldCreateLeftAndRightDecorationsWhenRequested() { $html = $this->getElement(); $this->assertRegexp('/]*(dojoType="dijit.form.VerticalRule")/', $html, $html); $this->assertRegexp('/]*(dojoType="dijit.form.VerticalRuleLabels")/', $html, $html); $this->assertContains('leftDecoration', $html); $this->assertContains('rightDecoration', $html); } public function testShouldIgnoreTopAndBottomDecorationsWhenPassed() { $html = $this->getElement(); $this->assertNotContains('topDecoration', $html); $this->assertNotContains('bottomDecoration', $html); } } // Call Zend_Dojo_View_Helper_VerticalSliderTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_VerticalSliderTest::main") { Zend_Dojo_View_Helper_VerticalSliderTest::main(); }