FormTextareaTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. // Call Zend_View_Helper_FormTextareaTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTextareaTest::main");
  5. }
  6. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  7. require_once 'Zend/View.php';
  8. require_once 'Zend/View/Helper/FormTextarea.php';
  9. /**
  10. * Zend_View_Helper_FormTextareaTest
  11. *
  12. * Tests formTextarea helper
  13. *
  14. * @uses PHPUnit_Framework_TestCase
  15. */
  16. class Zend_View_Helper_FormTextareaTest extends PHPUnit_Framework_TestCase
  17. {
  18. /**
  19. * Runs the test methods of this class.
  20. *
  21. * @access public
  22. * @static
  23. */
  24. public static function main()
  25. {
  26. require_once "PHPUnit/TextUI/TestRunner.php";
  27. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTextareaTest");
  28. $result = PHPUnit_TextUI_TestRunner::run($suite);
  29. }
  30. /**
  31. * Sets up the fixture, for example, open a network connection.
  32. * This method is called before a test is executed.
  33. *
  34. * @access protected
  35. */
  36. protected function setUp()
  37. {
  38. $this->view = new Zend_View();
  39. $this->helper = new Zend_View_Helper_FormTextarea();
  40. $this->helper->setView($this->view);
  41. }
  42. /**
  43. * ZF-1666
  44. */
  45. public function testCanDisableElement()
  46. {
  47. $html = $this->helper->formTextarea(array(
  48. 'name' => 'foo',
  49. 'value' => 'bar',
  50. 'attribs' => array('disable' => true)
  51. ));
  52. $this->assertRegexp('/<textarea[^>]*?(disabled="disabled")/', $html);
  53. }
  54. /**
  55. * ZF-1666
  56. */
  57. public function testDisablingElementDoesNotRenderHiddenElements()
  58. {
  59. $html = $this->helper->formTextarea(array(
  60. 'name' => 'foo',
  61. 'value' => 'bar',
  62. 'attribs' => array('disable' => true)
  63. ));
  64. $this->assertNotRegexp('/<textarea[^>]*?(type="hidden")/', $html);
  65. }
  66. }
  67. // Call Zend_View_Helper_FormTextareaTest::main() if this source file is executed directly.
  68. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTextareaTest::main") {
  69. Zend_View_Helper_FormTextareaTest::main();
  70. }