SliderTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category ZendX
  16. * @package ZendX_JQuery
  17. * @subpackage View
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once "jQueryTestCase.php";
  23. require_once "ZendX/JQuery/View/Helper/Slider.php";
  24. class ZendX_JQuery_View_SliderTest extends ZendX_JQuery_View_jQueryTestCase
  25. {
  26. public function testCallingInViewEnablesJQueryHelper()
  27. {
  28. $element = $this->view->slider("element", "");
  29. $this->assertTrue($this->jquery->isEnabled());
  30. $this->assertTrue($this->jquery->uiIsEnabled());
  31. }
  32. public function testShouldAppendToJqueryHelper()
  33. {
  34. $element = $this->view->slider("elem1", "", array("option" => "true"));
  35. $jquery = $this->view->jQuery()->__toString();
  36. $this->assertContains('slider(', $jquery);
  37. $this->assertContains('"option":"true"', $jquery);
  38. }
  39. public function testShouldBuiltSliderElementsWith15API()
  40. {
  41. $this->view->jQuery()->setUiVersion("1.5.2");
  42. $element = $this->view->slider("elem1", "75", array(), array());
  43. $this->assertEquals(
  44. array(
  45. '$("#elem1-slider").slider({"handles":[{"start":"75"}],"change":function(e, ui) {
  46. $("#elem1").attr("value", $("#elem1-slider").slider("value", 0));
  47. }
  48. });'
  49. ), $this->jquery->getOnLoadActions());
  50. $this->assertContains("<div", $element);
  51. $this->assertContains('<div class="ui-slider-handle"></div>', $element);
  52. $this->assertContains('<input', $element);
  53. $this->assertContains('type="hidden"', $element);
  54. $this->assertContains('id="elem1"', $element);
  55. $this->assertContains('id="elem1-slider"', $element);
  56. }
  57. public function testShouldBuiltSliderElementsWith17API()
  58. {
  59. $this->view->jQuery()->setUiVersion("1.7.2");
  60. $element = $this->view->slider("elem1", "75", array(), array());
  61. $this->assertEquals(
  62. array(
  63. '$("#elem1-slider").slider({"values":["75"],"change":function(e, ui) {
  64. $("#elem1").attr("value", $("#elem1-slider").slider("values", 0));
  65. }
  66. });'
  67. ), $this->jquery->getOnLoadActions());
  68. $this->assertContains("<div", $element);
  69. $this->assertContains('<div class="ui-slider-handle"></div>', $element);
  70. $this->assertContains('<input', $element);
  71. $this->assertContains('type="hidden"', $element);
  72. $this->assertContains('id="elem1"', $element);
  73. $this->assertContains('id="elem1-slider"', $element);
  74. }
  75. public function testShouldAllowMultipleSliders()
  76. {
  77. $element = $this->view->slider("elem1", "0", array('sliderCount' => 3), array());
  78. }
  79. }