OSDN Git Service

- [merged] IDEAS/Ideas_Extended_Viewclass branch with trunk.
[ethna/ethna.git] / test / Ethna_ViewClass_FormHelper_Test.php
1 <?php
2 /**
3  *  Ethna_ViewClass_FormHelper_Test.php
4  *
5  *  @package Ethna
6  *  @author Yoshinari Takaoka <takaoka@beatcraft.com>
7  */
8
9 require_once ETHNA_INSTALL_BASE . '/test/Ethna_MockProject.php';
10
11 /**
12  *  Ethna_ViewClass のうち、フォームヘルパ
13  *  に関連するテストケースを集めたクラス
14  *
15  *  @package Ethna
16  *  @author Yoshinari Takaoka <takaoka@beatcraft.com>
17  *  @access public
18  */
19 class Ethna_ViewClass_FormHelper_Test extends Ethna_UnitTestBase
20 {
21     var $project;
22
23     function setUp()
24     {
25         $this->project =& new Ethna_MockProject();
26         $this->project->create();
27     }
28
29     function tearDown()
30     {
31         $this->project->delete();
32         unset($GLOBALS['_Ethna_controller']);
33     }
34
35     function test_formhelper_Text()
36     {
37         $action_name = $tpl_name = 'texttest';
38         $action_skel = ETHNA_TEST_SKELDIR . 'skel.action.formhelper.php';
39         $this->project->runCmd('add-action',
40                                array(
41                                    '-s',
42                                    $action_skel,
43                                    $action_name,
44                                )
45         );
46         $tpl_skel = ETHNA_TEST_SKELTPLDIR . 'skel.template.text.tpl';
47         $this->project->runCmd('add-template',
48                                array(
49                                    '-s',
50                                    $tpl_skel,
51                                    $tpl_name,
52                                )
53         );
54         $submit_value = array(
55             'text_setactval' => 'abcd',
56         );
57         $result = $this->project->runMain($action_name, $submit_value);
58         $this->assertPattern('#<input type="text" name="text_noval" value="" />#', $result);
59         $this->assertPattern('#<input type="text" name="text_setactval" value="abcd" />#', $result);
60         $this->assertPattern('#<input value="1234" type="text" name="text_settplval" />#', $result);
61     }
62
63     function test_formhelper_Textarea()
64     {
65         $action_name = $tpl_name = 'textareatest';
66         $action_skel = ETHNA_TEST_SKELDIR . 'skel.action.formhelper.php';
67         $this->project->runCmd('add-action',
68                                array(
69                                    '-s',
70                                    $action_skel,
71                                    $action_name,
72                                )
73         );
74         $tpl_skel = ETHNA_TEST_SKELTPLDIR . 'skel.template.textarea.tpl';
75         $this->project->runCmd('add-template',
76                                array(
77                                    '-s',
78                                    $tpl_skel,
79                                    $tpl_name,
80                                )
81         );
82         $submit_value = array(
83             'textarea_setactval' => 'input',
84         );
85         $result = $this->project->runMain($action_name, $submit_value);
86
87         $this->assertPattern('#<textarea name="textarea_noval"></textarea>#', $result);
88         $this->assertPattern('#<textarea name="textarea_setactval">input</textarea>#', $result);
89         $this->assertPattern('#<textarea value="foo" name="textarea_settplval">foo</textarea>#', $result);
90     }
91 }
92
93 ?>