DialogContainerTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/DialogContainer.php";
  24. class ZendX_JQuery_View_DialogContainerTest extends ZendX_JQuery_View_jQueryTestCase
  25. {
  26. public function testCallingInViewEnablesJQueryHelper()
  27. {
  28. $element = $this->view->dialogContainer("element", "");
  29. $this->assertTrue($this->jquery->isEnabled());
  30. $this->assertTrue($this->jquery->uiIsEnabled());
  31. }
  32. public function testShouldAppendToJqueryHelper()
  33. {
  34. $element = $this->view->dialogContainer("elem1", "", array("option" => "true"));
  35. $jquery = $this->jquery->__toString();
  36. $this->assertContains('dialog(', $jquery);
  37. $this->assertContains('"option":"true"', $jquery);
  38. }
  39. public function testShouldCreateDivContainer()
  40. {
  41. $element = $this->view->dialogContainer("elem1", "", array(), array());
  42. $this->assertEquals(array('$("#elem1").dialog({});'), $this->jquery->getOnLoadActions());
  43. $this->assertContains("<div", $element);
  44. $this->assertContains('id="elem1"', $element);
  45. $this->assertContains("</div>", $element);
  46. }
  47. /**
  48. * @group ZF-4685
  49. */
  50. public function testUsingJsonExprForResizeShouldBeValidJsCallbackRegression()
  51. {
  52. $params = array(
  53. "resize" => new Zend_Json_Expr("doMyThingAtResize"),
  54. );
  55. $this->view->dialogContainer("dialog1", "Some text", $params);
  56. $actions = $this->jquery->getOnLoadActions();
  57. $this->assertEquals(array('$("#dialog1").dialog({"resize":doMyThingAtResize});'), $actions);
  58. }
  59. }