SubFormTest.php 4.1 KB

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