OSDN Git Service

207e3cd6b0d1c5363831bd8b24c8e403b3e56738
[ethna/ethna.git] / test / Ethna_ActionForm_FormTemplate_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_ActionForm_FormTemplate_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 // {{{  Ethna_FormTemplate_ActionForm
11 /**
12  *  Test ActionForm (Form Template) 
13  *
14  *  @access public
15  */
16 class Ethna_FormTemplate_ActionForm extends Ethna_ActionForm
17 {
18     var $form_template = array(
19        'normal' => array(
20            'name'      => '通常のフォームテンプレート用定義',
21            'required'  => false,
22            'form_type' => FORM_TYPE_SELECT,
23            'type'      => VAR_TYPE_INT,
24        ),
25        'syntax_sugar' => array(
26            'name'      => 'シンタックスシュガー用定義',
27            'required'  => true,
28            'form_type' => FORM_TYPE_TEXT,
29            'type'      => VAR_TYPE_STRING,
30        ),
31     );
32 }
33 // }}}
34
35 // {{{  Ethna_FormTemplateTest_ActionForm
36 /**
37  *  Test ActionForm (Form Template) 
38  *
39  *  @access public
40  */
41 class Ethna_FormTemplateTest_ActionForm extends Ethna_FormTemplate_ActionForm
42 {
43     var $form = array(
44        'normal' => array(),
45        'syntax_sugar',  //  シンタックスシュガー
46     );
47 }
48 // }}}
49
50 // {{{  Ethna_ActionForm_FormTemplate_Test
51 /**
52  *  Test Case For Ethna_ActionForm(Form Template)
53  *
54  *  @access public
55  */
56 class Ethna_ActionForm_FormTemplate_Test extends Ethna_UnitTestBase
57 {
58     var $local_af;
59
60     function setUp()
61     {
62         //   REQUEST_METHOD を設定しないと
63         //   フォームテンプレートが初期化されない
64         $_SERVER['REQUEST_METHOD'] = 'POST';
65         $this->local_af =& new Ethna_FormTemplateTest_ActionForm($this->ctl); 
66     }
67
68     function tearDown()
69     {
70         $_SERVER['REQUEST_METHOD'] = NULL;
71         $this->local_af = NULL;
72     }
73
74     // {{{ normal form template
75     function test_formtemplate_normal()
76     {
77         $normal_def = $this->local_af->getDef('normal');
78         $this->assertEqual($normal_def['name'], '通常のフォームテンプレート用定義');
79         $this->assertEqual($normal_def['required'], false);
80         $this->assertEqual($normal_def['form_type'], FORM_TYPE_SELECT);
81         $this->assertEqual($normal_def['type'], VAR_TYPE_INT);
82     }
83     // }}}
84
85     // {{{ syntax sugar 
86     function test_formtemplate_syntaxsugar()
87     {
88         $syntax_sugar_def = $this->local_af->getDef('syntax_sugar');
89         $this->assertEqual($syntax_sugar_def['name'], 'シンタックスシュガー用定義');
90         $this->assertEqual($syntax_sugar_def['required'], true);
91         $this->assertEqual($syntax_sugar_def['form_type'], FORM_TYPE_TEXT);
92         $this->assertEqual($syntax_sugar_def['type'], VAR_TYPE_STRING);
93     }
94     // }}}
95 }
96 // }}}
97 ?>