2
0

SimpleTextareaTest.php 3.6 KB

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