~clinton-collins/familyproject/trunk

« back to all changes in this revision

Viewing changes to ZendFramework/tests/Zend/Dojo/DojoTest.php

  • Committer: Clinton Collins
  • Date: 2009-06-26 19:54:58 UTC
  • Revision ID: clinton.collins@gmail.com-20090626195458-5ebba0qcvo15xlpy
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
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");
 
5
}
 
6
 
 
7
require_once dirname(__FILE__) . '/../../TestHelper.php';
 
8
 
 
9
/** Zend_Dojo */
 
10
require_once 'Zend/Dojo.php';
 
11
 
 
12
/** Zend_Form */
 
13
require_once 'Zend/Form.php';
 
14
 
 
15
/** Zend_Form_Element */
 
16
require_once 'Zend/Form/Element.php';
 
17
 
 
18
/** Zend_Form_SubForm */
 
19
require_once 'Zend/Form/SubForm.php';
 
20
 
 
21
/** Zend_View */
 
22
require_once 'Zend/View.php';
 
23
 
 
24
/**
 
25
 * Test class for Zend_Dojo
 
26
 */
 
27
class Zend_Dojo_DojoTest extends PHPUnit_Framework_TestCase 
 
28
{
 
29
    /**
 
30
     * Runs the test methods of this class.
 
31
     *
 
32
     * @return void
 
33
     */
 
34
    public static function main()
 
35
    {
 
36
        $suite  = new PHPUnit_Framework_TestSuite("Zend_Dojo_DojoTest");
 
37
        $result = PHPUnit_TextUI_TestRunner::run($suite);
 
38
    }
 
39
 
 
40
    /**
 
41
     * Sets up the fixture, for example, open a network connection.
 
42
     * This method is called before a test is executed.
 
43
     *
 
44
     * @return void
 
45
     */
 
46
    public function setUp()
 
47
    {
 
48
    }
 
49
 
 
50
    /**
 
51
     * Tears down the fixture, for example, close a network connection.
 
52
     * This method is called after a test is executed.
 
53
     *
 
54
     * @return void
 
55
     */
 
56
    public function tearDown()
 
57
    {
 
58
    }
 
59
 
 
60
    public function getForm()
 
61
    {
 
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);
 
75
        return $form;
 
76
    }
 
77
 
 
78
    public function testEnableFormShouldSetAppropriateDecoratorAndElementPaths()
 
79
    {
 
80
        $form = $this->getForm();
 
81
        Zend_Dojo::enableForm($form);
 
82
 
 
83
        $decPluginLoader = $form->getPluginLoader('decorator');
 
84
        $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
 
85
        $this->assertTrue(is_array($paths));
 
86
 
 
87
        $elPluginLoader = $form->getPluginLoader('element');
 
88
        $paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element');
 
89
        $this->assertTrue(is_array($paths));
 
90
 
 
91
        $decPluginLoader = $form->baz->getPluginLoader('decorator');
 
92
        $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
 
93
        $this->assertTrue(is_array($paths));
 
94
 
 
95
        $decPluginLoader = $form->foobar->getPluginLoader();
 
96
        $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
 
97
        $this->assertTrue(is_array($paths));
 
98
 
 
99
        $decPluginLoader = $form->sub->getPluginLoader('decorator');
 
100
        $paths = $decPluginLoader->getPaths('Zend_Dojo_Form_Decorator');
 
101
        $this->assertTrue(is_array($paths));
 
102
 
 
103
        $elPluginLoader = $form->sub->getPluginLoader('element');
 
104
        $paths = $elPluginLoader->getPaths('Zend_Dojo_Form_Element');
 
105
        $this->assertTrue(is_array($paths));
 
106
    }
 
107
 
 
108
    public function testEnableFormShouldSetAppropriateDefaultDisplayGroup()
 
109
    {
 
110
        $form = $this->getForm();
 
111
        Zend_Dojo::enableForm($form);
 
112
        $this->assertEquals('Zend_Dojo_Form_DisplayGroup', $form->getDefaultDisplayGroupClass());
 
113
    }
 
114
 
 
115
    public function testEnableFormShouldSetAppropriateViewHelperPaths()
 
116
    {
 
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));
 
123
    }
 
124
 
 
125
    public function testEnableViewShouldSetAppropriateViewHelperPaths()
 
126
    {
 
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));
 
132
    }
 
133
}
 
134
 
 
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();
 
138
}