ResetTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // Call Zend_Form_Element_ResetTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_Form_Element_ResetTest::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/Reset.php';
  10. /**
  11. * Test class for Zend_Form_Element_Reset
  12. */
  13. class Zend_Form_Element_ResetTest 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_ResetTest");
  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_Reset('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 testResetElementSubclassesSubmitElement()
  46. {
  47. $this->assertTrue($this->element instanceof Zend_Form_Element_Submit);
  48. }
  49. public function testResetElementSubclassesXhtmlElement()
  50. {
  51. $this->assertTrue($this->element instanceof Zend_Form_Element_Xhtml);
  52. }
  53. public function testResetElementInstanceOfBaseElement()
  54. {
  55. $this->assertTrue($this->element instanceof Zend_Form_Element);
  56. }
  57. public function testResetElementUsesResetHelperInViewHelperDecoratorByDefault()
  58. {
  59. $this->_checkZf2794();
  60. $decorator = $this->element->getDecorator('viewHelper');
  61. $this->assertTrue($decorator instanceof Zend_Form_Decorator_ViewHelper);
  62. $decorator->setElement($this->element);
  63. $helper = $decorator->getHelper();
  64. $this->assertEquals('formReset', $helper);
  65. }
  66. /**
  67. * Used by test methods susceptible to ZF-2794, marks a test as incomplete
  68. *
  69. * @link http://framework.zend.com/issues/browse/ZF-2794
  70. * @return void
  71. */
  72. protected function _checkZf2794()
  73. {
  74. if (strtolower(substr(PHP_OS, 0, 3)) == 'win' && version_compare(PHP_VERSION, '5.1.4', '=')) {
  75. $this->markTestIncomplete('Error occurs for PHP 5.1.4 on Windows');
  76. }
  77. }
  78. }
  79. // Call Zend_Form_Element_ResetTest::main() if this source file is executed directly.
  80. if (PHPUnit_MAIN_METHOD == "Zend_Form_Element_ResetTest::main") {
  81. Zend_Form_Element_ResetTest::main();
  82. }