SubFormTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_Dojo
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 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_Dojo_Form_SubFormTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Dojo_Form_SubFormTest::main");
  25. }
  26. /** Zend_Dojo_Form_SubForm */
  27. require_once 'Zend/Dojo/Form/SubForm.php';
  28. /** Zend_View */
  29. require_once 'Zend/View.php';
  30. /**
  31. * Test class for Zend_Dojo_SubForm
  32. *
  33. * @category Zend
  34. * @package Zend_Dojo
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @group Zend_Dojo
  39. * @group Zend_Dojo_Form
  40. */
  41. class Zend_Dojo_Form_SubFormTest extends PHPUnit_Framework_TestCase
  42. {
  43. /**
  44. * Runs the test methods of this class.
  45. *
  46. * @return void
  47. */
  48. public static function main()
  49. {
  50. $suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_Form_SubFormTest");
  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->form = new Zend_Dojo_Form_SubForm();
  62. $this->form->addElement('TextBox', 'foo')
  63. ->addDisplayGroup(array('foo'), 'dg')
  64. ->setView(new Zend_View());
  65. }
  66. /**
  67. * Tears down the fixture, for example, close a network connection.
  68. * This method is called after a test is executed.
  69. *
  70. * @return void
  71. */
  72. public function tearDown()
  73. {
  74. }
  75. public function testDojoFormDecoratorPathShouldBeRegisteredByDefault()
  76. {
  77. $paths = $this->form->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator');
  78. $this->assertTrue(is_array($paths));
  79. }
  80. public function testDojoFormElementPathShouldBeRegisteredByDefault()
  81. {
  82. $paths = $this->form->getPluginLoader('element')->getPaths('Zend_Dojo_Form_Element');
  83. $this->assertTrue(is_array($paths));
  84. }
  85. public function testDojoFormElementDecoratorPathShouldBeRegisteredByDefault()
  86. {
  87. $paths = $this->form->foo->getPluginLoader('decorator')->getPaths('Zend_Dojo_Form_Decorator');
  88. $this->assertTrue(is_array($paths));
  89. }
  90. public function testDojoFormDisplayGroupDecoratorPathShouldBeRegisteredByDefault()
  91. {
  92. $paths = $this->form->dg->getPluginLoader()->getPaths('Zend_Dojo_Form_Decorator');
  93. $this->assertTrue(is_array($paths));
  94. }
  95. public function testDefaultDisplayGroupClassShouldBeDojoDisplayGroupByDefault()
  96. {
  97. $this->assertEquals('Zend_Dojo_Form_DisplayGroup', $this->form->getDefaultDisplayGroupClass());
  98. }
  99. public function testDefaultDecoratorsShouldIncludeContentPane()
  100. {
  101. $this->assertNotNull($this->form->getDecorator('ContentPane'));
  102. }
  103. public function testShouldRegisterDojoViewHelperPath()
  104. {
  105. $view = $this->form->getView();
  106. $loader = $view->getPluginLoader('helper');
  107. $paths = $loader->getPaths('Zend_Dojo_View_Helper');
  108. $this->assertTrue(is_array($paths));
  109. }
  110. }
  111. // Call Zend_Dojo_Form_SubFormTest::main() if this source file is executed directly.
  112. if (PHPUnit_MAIN_METHOD == "Zend_Dojo_Form_SubFormTest::main") {
  113. Zend_Dojo_Form_SubFormTest::main();
  114. }