2
// Call Zend_Dojo_FormTest::main() if this source file is executed directly.
3
if (!defined("PHPUnit_MAIN_METHOD")) {
4
define("PHPUnit_MAIN_METHOD", "Zend_Dojo_DojoTest::main");
7
require_once dirname(__FILE__) . '/../../TestHelper.php';
10
require_once 'Zend/Dojo.php';
13
require_once 'Zend/Form.php';
15
/** Zend_Form_Element */
16
require_once 'Zend/Form/Element.php';
18
/** Zend_Form_SubForm */
19
require_once 'Zend/Form/SubForm.php';
22
require_once 'Zend/View.php';
25
* Test class for Zend_Dojo
27
class Zend_Dojo_DojoTest extends PHPUnit_Framework_TestCase
30
* Runs the test methods of this class.
34
public static function main()
36
$suite = new PHPUnit_Framework_TestSuite("Zend_Dojo_DojoTest");
37
$result = PHPUnit_TextUI_TestRunner::run($suite);
41
* Sets up the fixture, for example, open a network connection.
42
* This method is called before a test is executed.
46
public function setUp()
51
* Tears down the fixture, for example, close a network connection.
52
* This method is called after a test is executed.
56
public function tearDown()
60
public function getForm()
62
$form = new Zend_Form();
63
$form->addElement('text', 'foo')
64
->addElement('text', 'bar')
65
->addElement('text', 'baz')
66
->addElement('text', 'bat');
67
$subForm = new Zend_Form_SubForm();
68
$subForm->addElement('text', 'foo')
69
->addElement('text', 'bar')
70
->addElement('text', 'baz')
71
->addElement('text', 'bat');
72
$form->addDisplayGroup(array('foo', 'bar'), 'foobar')
73
->addSubForm($subForm, 'sub')
74
->setView(new Zend_View);
78
public function testEnableFormShouldSetAppropriateDecoratorAndElementPaths()
80
$form = $this->getForm();
81
Zend_Dojo::enableForm($form);
83
$decPluginLoader = $form->getPluginLoader('decorator');
84
$paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
85
$this->assertTrue(is_array($paths));
87
$elPluginLoader = $form->getPluginLoader('element');
88
$paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element');
89
$this->assertTrue(is_array($paths));
91
$decPluginLoader = $form->baz->getPluginLoader('decorator');
92
$paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
93
$this->assertTrue(is_array($paths));
95
$decPluginLoader = $form->foobar->getPluginLoader();
96
$paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
97
$this->assertTrue(is_array($paths));
99
$decPluginLoader = $form->sub->getPluginLoader('decorator');
100
$paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
101
$this->assertTrue(is_array($paths));
103
$elPluginLoader = $form->sub->getPluginLoader('element');
104
$paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element');
105
$this->assertTrue(is_array($paths));
108
public function testEnableFormShouldSetAppropriateDefaultDisplayGroup()
110
$form = $this->getForm();
111
Zend_Dojo::enableForm($form);
112
$this->assertEquals('Zend_Dojo_Form_DisplayGroup', $form->getDefaultDisplayGroupClass());
115
public function testEnableFormShouldSetAppropriateViewHelperPaths()
117
$form = $this->getForm();
118
Zend_Dojo::enableForm($form);
119
$view = $form->getView();
120
$helperLoader = $view->getPluginLoader('helper');
121
$paths = $helperLoader->getPaths('Zend_Dojo_View_Helper');
122
$this->assertTrue(is_array($paths));
125
public function testEnableViewShouldSetAppropriateViewHelperPaths()
127
$view = new Zend_View;
128
Zend_Dojo::enableView($view);
129
$helperLoader = $view->getPluginLoader('helper');
130
$paths = $helperLoader->getPaths('Zend_Dojo_View_Helper');
131
$this->assertTrue(is_array($paths));
135
// Call Zend_Dojo_DojoTest::main() if this source file is executed directly.
136
if (PHPUnit_MAIN_METHOD == "Zend_Dojo_DojoTest::main") {
137
Zend_Dojo_DojoTest::main();