TextareaTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. // Call Zend_Form_Element_TextareaTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_TextareaTest::main");
  5. }
  6. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  7. require_once "PHPUnit/Framework/TestCase.php";
  8. require_once "PHPUnit/Framework/TestSuite.php";
  9. require_once 'Zend/Form/Element/Textarea.php';
  10. /**
  11. * Test class for Zend_Form_Element_Textarea
  12. */
  13. class Zend_Form_Element_TextareaTest extends PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * Runs the test methods of this class.
  17. *
  18. * @return void
  19. */
  20. public static function main()
  21. {
  22. require_once "PHPUnit/TextUI/TestRunner.php";
  23. $suite = new PHPUnit_Framework_TestSuite("Zend_Form_Element_TextareaTest");
  24. $result = PHPUnit_TextUI_TestRunner::run($suite);
  25. }
  26. /**
  27. * Sets up the fixture, for example, open a network connection.
  28. * This method is called before a test is executed.
  29. *
  30. * @return void
  31. */
  32. public function setUp()
  33. {
  34. $this->element = new Zend_Form_Element_Textarea('foo');
  35. }
  36. /**
  37. * Tears down the fixture, for example, close a network connection.
  38. * This method is called after a test is executed.
  39. *
  40. * @return void
  41. */
  42. public function tearDown()
  43. {
  44. }
  45. public function testTextareaElementSubclassesXhtmlElement()
  46. {
  47. $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml);
  48. }
  49. public function testTextareaElementInstanceOfBaseElement()
  50. {
  51. $this->assertTrue($this->element instanceof Zend_Form_Element);
  52. }
  53. public function testTextareaElementUsesTextareaHelperInViewHelperDecoratorByDefault()
  54. {
  55. $this->_checkZf2794();
  56. $decorator = $this->element->getDecorator('viewHelper');
  57. $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper);
  58. $decorator->setElement($this->element);
  59. $helper = $decorator->getHelper();
  60. $this->assertEquals('formTextarea', $helper);
  61. }
  62. /**
  63. * Used by test methods susceptible to ZF-2794, marks a test as incomplete
  64. *
  65. * @link http://framework.zend.com/issues/browse/ZF-2794
  66. * @return void
  67. */
  68. protected function _checkZf2794()
  69. {
  70. if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) {
  71. $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows');
  72. }
  73. }
  74. }
  75. // Call Zend_Form_Element_TextareaTest::main() if this source file is executed directly.
  76. if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_TextareaTest::main") {
  77. Zend_Form_Element_TextareaTest::main();
  78. }