2 // vim: foldmethod=marker
4 * Ethna_ActionForm_Validator_Required_Test.php
6 * @author Yoshinari Takaoka <takaoka@beatcraft.com>
10 // {{{ Ethna_ActionForm_Validator_Required_Test
12 * Test Case For Ethna_ActionForm(Required Validator)
16 class Ethna_ActionForm_Validator_Required_Test extends Ethna_UnitTestBase
20 $this->af->use_validator_plugin = false;
21 $this->af->clearFormVars();
22 $this->af->form = array();
26 // {{{ Validator Required Integer.
27 function test_Validate_Required_Integer()
30 'type' => VAR_TYPE_INT,
31 'form_type' => FORM_TYPE_TEXT,
34 $this->af->setDef('input', $form_def);
36 $this->af->validate();
37 $this->assertTrue($this->ae->isError('input'));
40 $this->af->set('input', 5);
41 $this->af->validate();
42 $this->assertFalse($this->ae->isError('input'));
45 $this->af->set('input', null);
46 $this->af->validate();
47 $this->assertTrue($this->ae->isError('input'));
51 // {{{ Validator Required Float.
52 function test_Validate_Required_Float()
55 'type' => VAR_TYPE_FLOAT,
56 'form_type' => FORM_TYPE_TEXT,
59 $this->af->setDef('input', $form_def);
61 $this->af->validate();
62 $this->assertTrue($this->ae->isError('input'));
65 $this->af->set('input', 4.999999);
66 $this->af->validate();
67 $this->assertFalse($this->ae->isError('input'));
70 $this->af->set('input', null);
71 $this->af->validate();
72 $this->assertTrue($this->ae->isError('input'));
76 // {{{ Validator Required Datetime.
77 function test_Validate_Required_DateTime()
80 'type' => VAR_TYPE_DATETIME,
81 'form_type' => FORM_TYPE_TEXT,
84 $this->af->setDef('input', $form_def);
86 $this->af->validate();
87 $this->assertTrue($this->ae->isError('input'));
90 $this->af->set('input', '1999-12-31');
91 $this->af->validate();
92 $this->assertFalse($this->ae->isError('input'));
95 $this->af->set('input', null);
96 $this->af->validate();
97 $this->assertTrue($this->ae->isError('input'));
101 // {{{ Validator Required String.
102 function test_Validate_Min_String()
105 'type' => VAR_TYPE_STRING,
106 'form_type' => FORM_TYPE_TEXT,
109 $this->af->setDef('input', $form_def);
111 $this->af->validate();
112 $this->assertTrue($this->ae->isError('input'));
115 $this->af->set('input', 'ああああ');
116 $this->af->validate();
117 $this->assertFalse($this->ae->isError('input'));
120 $this->af->set('input', 'abcd');
121 $this->af->validate();
122 $this->assertFalse($this->ae->isError('input'));
125 $this->af->set('input', null);
126 $this->af->validate();
127 $this->assertTrue($this->ae->isError('input'));
131 // {{{ Validator Max File.
132 function test_Validate_Max_File()
134 // skipped because we can't bypass
135 // is_uploaded_file function.