FormTextareaTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_View
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 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_View_Helper_FormTextareaTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FormTextareaTest::main");
  25. }
  26. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  27. require_once 'Zend/View.php';
  28. require_once 'Zend/View/Helper/FormTextarea.php';
  29. /**
  30. * Zend_View_Helper_FormTextareaTest
  31. *
  32. * Tests formTextarea helper
  33. *
  34. * @uses PHPUnit_Framework_TestCase
  35. *
  36. * @category Zend
  37. * @package Zend_View
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_View
  42. * @group Zend_View_Helper
  43. */
  44. class Zend_View_Helper_FormTextareaTest extends PHPUnit_Framework_TestCase
  45. {
  46. /**
  47. * Runs the test methods of this class.
  48. *
  49. * @access public
  50. * @static
  51. */
  52. public static function main()
  53. {
  54. require_once "PHPUnit/TextUI/TestRunner.php";
  55. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FormTextareaTest");
  56. $result = PHPUnit_TextUI_TestRunner::run($suite);
  57. }
  58. /**
  59. * Sets up the fixture, for example, open a network connection.
  60. * This method is called before a test is executed.
  61. *
  62. * @access protected
  63. */
  64. protected function setUp()
  65. {
  66. $this->view = new Zend_View();
  67. $this->helper = new Zend_View_Helper_FormTextarea();
  68. $this->helper->setView($this->view);
  69. }
  70. /**
  71. * ZF-1666
  72. */
  73. public function testCanDisableElement()
  74. {
  75. $html = $this->helper->formTextarea(array(
  76. 'name' => 'foo',
  77. 'value' => 'bar',
  78. 'attribs' => array('disable' => true)
  79. ));
  80. $this->assertRegexp('/<textarea[^>]*?(disabled="disabled")/', $html);
  81. }
  82. /**
  83. * ZF-1666
  84. */
  85. public function testDisablingElementDoesNotRenderHiddenElements()
  86. {
  87. $html = $this->helper->formTextarea(array(
  88. 'name' => 'foo',
  89. 'value' => 'bar',
  90. 'attribs' => array('disable' => true)
  91. ));
  92. $this->assertNotRegexp('/<textarea[^>]*?(type="hidden")/', $html);
  93. }
  94. }
  95. // Call Zend_View_Helper_FormTextareaTest::main() if this source file is executed directly.
  96. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FormTextareaTest::main") {
  97. Zend_View_Helper_FormTextareaTest::main();
  98. }