SimpleTextareaTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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-2009 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_Form_Element_SimpleTextareaTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_Element_SimpleTextareaTest::main");
  25. }
  26. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  27. /** Zend_Dojo_Form_Element_SimpleTextarea */
  28. require_once 'Zend/Dojo/Form/Element/SimpleTextarea.php';
  29. /** Zend_View */
  30. require_once 'Zend/View.php';
  31. /** Zend_Dojo */
  32. require_once 'Zend/Dojo.php';
  33. /** Zend_Registry */
  34. require_once 'Zend/Registry.php';
  35. /** Zend_Dojo_View_Helper_Dojo */
  36. require_once 'Zend/Dojo/View/Helper/Dojo.php';
  37. /**
  38. * Test class for Zend_Dojo_Form_Element_SimpleTextarea.
  39. *
  40. * @category Zend
  41. * @package Zend_Dojo
  42. * @subpackage UnitTests
  43. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  44. * @license http://framework.zend.com/license/new-bsd New BSD License
  45. * @group Zend_Dojo
  46. * @group Zend_Dojo_Form
  47. */
  48. class Zend_Dojo_Form_Element_SimpleTextareaTest extends PHPUnit_Framework_TestCase
  49. {
  50. /**
  51. * Runs the test methods of this class.
  52. *
  53. * @return void
  54. */
  55. public static function main()
  56. {
  57. $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_Element_SimpleTextareaTest");
  58. $result = PHPUnit_TextUI_TestRunner::run($suite);
  59. }
  60. /**
  61. * Sets up the fixture, for example, open a network connection.
  62. * This method is called before a test is executed.
  63. *
  64. * @return void
  65. */
  66. public function setUp()
  67. {
  68. Zend_Registry::_unsetInstance();
  69. Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
  70. $this->view = $this->getView();
  71. $this->element = $this->getElement();
  72. $this->element->setView($this->view);
  73. }
  74. /**
  75. * Tears down the fixture, for example, close a network connection.
  76. * This method is called after a test is executed.
  77. *
  78. * @return void
  79. */
  80. public function tearDown()
  81. {
  82. }
  83. public function getView()
  84. {
  85. require_once 'Zend/View.php';
  86. $view = new Zend_View();
  87. Zend_Dojo::enableView($view);
  88. return $view;
  89. }
  90. public function getElement()
  91. {
  92. $element = new Zend_Dojo_Form_Element_SimpleTextarea(
  93. 'foo',
  94. array(
  95. 'value' => 'some text',
  96. 'label' => 'SimpleTextarea',
  97. 'class' => 'someclass',
  98. 'style' => 'width: 100px;',
  99. )
  100. );
  101. return $element;
  102. }
  103. public function testShouldRenderSimpleTextareaDijit()
  104. {
  105. $html = $this->element->render();
  106. $this->assertContains('dojoType="dijit.form.SimpleTextarea"', $html);
  107. }
  108. }
  109. // Call Zend_Dojo_Form_Element_SimpleTextareaTest::main() if this source file is executed directly.
  110. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_Element_SimpleTextareaTest::main") {
  111. Zend_Dojo_Form_Element_SimpleTextareaTest::main();
  112. }