TextareaTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_Form
  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_Form_Element_TextareaTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_TextareaTest::main");
  25. }
  26. require_once 'Zend/Form/Element/Textarea.php';
  27. /**
  28. * Test class for Zend_Form_Element_Textarea
  29. *
  30. * @category Zend
  31. * @package Zend_Form
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @group Zend_Form
  36. */
  37. class Zend_Form_Element_TextareaTest extends PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * Runs the test methods of this class.
  41. *
  42. * @return void
  43. */
  44. public static function main()
  45. {
  46. $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_TextareaTest");
  47. $result = PHPUnit_TextUI_TestRunner::run($suite);
  48. }
  49. /**
  50. * Sets up the fixture, for example, open a network connection.
  51. * This method is called before a test is executed.
  52. *
  53. * @return void
  54. */
  55. public function setUp()
  56. {
  57. $this->element = new Zend_Form_Element_Textarea('foo');
  58. }
  59. /**
  60. * Tears down the fixture, for example, close a network connection.
  61. * This method is called after a test is executed.
  62. *
  63. * @return void
  64. */
  65. public function tearDown()
  66. {
  67. }
  68. public function testTextareaElementSubclassesXhtmlElement()
  69. {
  70. $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml);
  71. }
  72. public function testTextareaElementInstanceOfBaseElement()
  73. {
  74. $this->assertTrue($this->element instanceof Zend_Form_Element);
  75. }
  76. public function testTextareaElementUsesTextareaHelperInViewHelperDecoratorByDefault()
  77. {
  78. $this->_checkZf2794();
  79. $decorator = $this->element->getDecorator('viewHelper');
  80. $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper);
  81. $decorator->setElement($this->element);
  82. $helper = $decorator->getHelper();
  83. $this->assertEquals('formTextarea', $helper);
  84. }
  85. /**
  86. * Used by test methods susceptible to ZF-2794, marks a test as incomplete
  87. *
  88. * @link http://framework.zend.com/issues/browse/ZF-2794
  89. * @return void
  90. */
  91. protected function _checkZf2794()
  92. {
  93. if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) {
  94. $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows');
  95. }
  96. }
  97. }
  98. // Call Zend_Form_Element_TextareaTest::main() if this source file is executed directly.
  99. if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_TextareaTest::main") {
  100. Zend_Form_Element_TextareaTest::main();
  101. }