ResetTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_ResetTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_ResetTest::main");
  25. }
  26. require_once 'Zend/Form/Element/Reset.php';
  27. /**
  28. * Test class for Zend_Form_Element_Reset
  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_ResetTest 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_ResetTest");
  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_Reset('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 testResetElementSubclassesSubmitElement()
  69. {
  70. $this->assertTrue($this->element instanceof Zend_Form_Element_Submit);
  71. }
  72. public function testResetElementSubclassesXhtmlElement()
  73. {
  74. $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml);
  75. }
  76. public function testResetElementInstanceOfBaseElement()
  77. {
  78. $this->assertTrue($this->element instanceof Zend_Form_Element);
  79. }
  80. public function testResetElementUsesResetHelperInViewHelperDecoratorByDefault()
  81. {
  82. $this->_checkZf2794();
  83. $decorator = $this->element->getDecorator('viewHelper');
  84. $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper);
  85. $decorator->setElement($this->element);
  86. $helper = $decorator->getHelper();
  87. $this->assertEquals('formReset', $helper);
  88. }
  89. /**
  90. * Used by test methods susceptible to ZF-2794, marks a test as incomplete
  91. *
  92. * @link http://framework.zend.com/issues/browse/ZF-2794
  93. * @return void
  94. */
  95. protected function _checkZf2794()
  96. {
  97. if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) {
  98. $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows');
  99. }
  100. }
  101. }
  102. // Call Zend_Form_Element_ResetTest::main() if this source file is executed directly.
  103. if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_ResetTest::main") {
  104. Zend_Form_Element_ResetTest::main();
  105. }