ContentPaneTest.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 Zend
  16. * @package Zend_Dojo
  17. * @subpackage UnitTests
  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. // Call Zend_Dojo_View_Helper_ContentPaneTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Dojo_View_Helper_ContentPaneTest::main");
  25. }
  26. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  27. /** Zend_Dojo_View_Helper_ContentPane */
  28. require_once 'Zend/Dojo/View/Helper/ContentPane.php';
  29. /** Zend_View */
  30. require_once 'Zend/View.php';
  31. /** Zend_Registry */
  32. require_once 'Zend/Registry.php';
  33. /** Zend_Dojo_View_Helper_Dojo */
  34. require_once 'Zend/Dojo/View/Helper/Dojo.php';
  35. /**
  36. * Test class for Zend_Dojo_View_Helper_ContentPane.
  37. *
  38. * @category Zend
  39. * @package Zend_Dojo
  40. * @subpackage UnitTests
  41. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  42. * @license http://framework.zend.com/license/new-bsd New BSD License
  43. * @group Zend_Dojo
  44. * @group Zend_Dojo_View
  45. */
  46. class Zend_Dojo_View_Helper_ContentPaneTest extends PHPUnit_Framework_TestCase
  47. {
  48. /**
  49. * Runs the test methods of this class.
  50. *
  51. * @return void
  52. */
  53. public static function main()
  54. {
  55. $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_View_Helper_ContentPaneTest");
  56. $result = PHPUnit_TextUI_TestRunner::run($suite);
  57. }
  58. /**
  59. * Sets up the fixture, for example, open a network connection.
  60. * This method is called before a test is executed.
  61. *
  62. * @return void
  63. */
  64. public function setUp()
  65. {
  66. Zend_Registry::_unsetInstance();
  67. Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
  68. $this->view = $this->getView();
  69. $this->helper = new Zend_Dojo_View_Helper_ContentPane();
  70. $this->helper->setView($this->view);
  71. }
  72. /**
  73. * Tears down the fixture, for example, close a network connection.
  74. * This method is called after a test is executed.
  75. *
  76. * @return void
  77. */
  78. public function tearDown()
  79. {
  80. }
  81. public function getView()
  82. {
  83. require_once 'Zend/View.php';
  84. $view = new Zend_View();
  85. $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
  86. return $view;
  87. }
  88. public function getContainer()
  89. {
  90. return $this->view->contentPane('pane1', 'This is the pane content', array('title' => 'Pane 1'));
  91. }
  92. public function testShouldAllowDeclarativeDijitCreation()
  93. {
  94. $html = $this->getContainer();
  95. $this->assertRegexp('/<div[^>]*(dojoType="dijit.layout.ContentPane")/', $html, $html);
  96. }
  97. public function testShouldAllowProgrammaticDijitCreation()
  98. {
  99. Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
  100. $html = $this->getContainer();
  101. $this->assertNotRegexp('/<div[^>]*(dojoType="dijit.layout.ContentPane")/', $html);
  102. $this->assertNotNull($this->view->dojo()->getDijit('pane1'));
  103. }
  104. /**
  105. * @group ZF-3877
  106. */
  107. public function testContentPaneMarkupShouldNotContainNameAttribute()
  108. {
  109. $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1'));
  110. $this->assertNotContains('name="/', $html, $html);
  111. Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
  112. $html = $this->view->contentPane('pane1', 'This is the pane content', array('id' => 'pane', 'title' => 'Pane 1'));
  113. $this->assertNotContains('name="/', $html, $html);
  114. }
  115. /**
  116. * @group ZF-4522
  117. */
  118. public function testCaptureStartShouldReturnVoid()
  119. {
  120. $test = $this->view->contentPane()->captureStart('pane1');
  121. $this->view->contentPane()->captureEnd('pane1');
  122. $this->assertNull($test);
  123. }
  124. }
  125. // Call Zend_Dojo_View_Helper_ContentPaneTest::main() if this source file is executed directly.
  126. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_View_Helper_ContentPaneTest::main") {
  127. Zend_Dojo_View_Helper_ContentPaneTest::main();
  128. }