ResetTest.php 3.7 KB

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