--- /dev/null
+<?php
+/**
+ * Ethna_View_FormHelper_Test.php
+ *
+ * @package Ethna
+ * @author Yoshinari Takaoka <takaoka@beatcraft.com>
+ */
+
+require_once ETHNA_INSTALL_BASE . '/test/Ethna_MockProject.php';
+
+/**
+ * Ethna_ViewClass のうち、フォームヘルパ
+ * に関連するテストケースを集めたクラス
+ *
+ * @package Ethna
+ * @author Yoshinari Takaoka <takaoka@beatcraft.com>
+ * @access public
+ */
+class Ethna_View_FormHelper_Test extends Ethna_UnitTestBase
+{
+ var $project;
+
+ function setUp()
+ {
+ $this->project =& new Ethna_MockProject();
+ $this->project->create();
+ }
+
+ function tearDown()
+ {
+ $this->project->delete();
+ unset($GLOBALS['_Ethna_controller']);
+ }
+
+ function test_formhelper_Textarea()
+ {
+ $action_name = $tpl_name = 'textareatest';
+ $action_skel = ETHNA_TEST_SKELDIR . 'skel.action.formhelper.php';
+ $this->project->runCmd('add-action',
+ array(
+ '-s',
+ $action_skel,
+ $action_name,
+ )
+ );
+ $tpl_skel = ETHNA_TEST_SKELTPLDIR . 'skel.template.textarea.tpl';
+ $this->project->runCmd('add-template',
+ array(
+ '-s',
+ $tpl_skel,
+ $tpl_name,
+ )
+ );
+ $submit_value = array(
+ 'textarea_setactval' => 'input',
+ );
+ $result = $this->project->runMain($action_name, $submit_value);
+
+ // TODO: assert output
+ }
+}
+
+?>
* @var array form definition.
*/
var $form = array(
+ /** FORM_TYPE_TEXTAREA のテスト */
- // form_type = text
- 'text_string' => array(
- 'type' => VAR_TYPE_STRING,
- 'form_type' => FROM_TYPE_TEXT,
- 'name' => 'text_string',
- 'max' => '9',
- ),
- 'text_float' => array(
- 'type' => VAR_TYPE_FLOAT,
- 'form_type' => FROM_TYPE_TEXT,
- 'name' => 'text_float',
- 'max' => '10.999',
- ),
- 'text_int' => array(
- 'type' => VAR_TYPE_INT,
- 'form_type' => FROM_TYPE_TEXT,
- 'name' => 'text_int',
- 'max' => '-1',
+ // テンプレートでvalue属性を設定しない場合
+ 'textarea_noval' => array(
+ 'type' => VAR_TYPE_INT,
+ 'name' => 'textarea_noval',
+ 'form_type' => FORM_TYPE_TEXTAREA,
),
- 'text_datetime' => array(
- 'type' => VAR_TYPE_DATETIME,
- 'form_type' => FROM_TYPE_TEXT,
- 'name' => 'text_datetime',
- 'max' => '+1 day',
+ // アクションフォームに値が設定されており、
+ // テンプレートでvalue属性を設定しない場合
+ 'textarea_setactval' => array(
+ 'type' => VAR_TYPE_INT,
+ 'name' => 'textarea_setactval',
+ 'form_type' => FORM_TYPE_TEXTAREA,
),
-
- // form_type = textarea
- 'textarea_string' => array(
- 'type' => VAR_TYPE_STRING,
+ // テンプレートでvalue属性を設定した場合
+ 'textarea_settplval' => array(
+ 'type' => VAR_TYPE_INT,
+ 'name' => 'textarea_settplval',
'form_type' => FORM_TYPE_TEXTAREA,
- 'name' => 'textarea_string',
),
- );
-
- /**
- * Form input value convert filter : sample
- *
- * @access protected
- * @param mixed $value Form Input Value
- * @return mixed Converted result.
- */
- /*
- function _filter_sample($value)
- {
- // convert to upper case.
- return strtoupper($value);
- }
- */
+ );
}
/**
*/
function perform()
{
- return 'index';
+ return '{$action_name}';
}
}