OSDN Git Service

add smarty modifier: explode
[ethna/ethna.git] / test / Ethna_ActionForm_Validator_Strmincompat_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_ActionForm_Validator_Strmincompat_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 // {{{    Ethna_ActionForm_Validator_Strmincompat_Test
11 /**
12  *  Test Case For Ethna_ActionForm(Min Validator(2.3.x compatible))
13  *
14  *  @access public
15  */
16 class Ethna_ActionForm_Validator_Strmincompat_Test extends Ethna_UnitTestBase
17 {
18     function setUp()
19     {
20         $this->af->use_validator_plugin = false;
21         $this->af->clearFormVars();
22         $this->af->form = array();
23         $this->ae->clear();
24     }
25
26     // {{{ Validator Min string(2.3.x compatible). 
27     function test_Validate_Min_String_Compatible()
28     {
29         $form_def = array(
30                           'type'          => VAR_TYPE_STRING,
31                           'form_type'     => FORM_TYPE_TEXT,
32                           'required'      => true,
33                           'strmincompat'  => '4',  // 半角4文字、全角2文字
34                     );        
35         $this->af->setDef('input', $form_def);
36         
37         //   in ascii.
38         $this->af->set('input', 'abcd'); 
39         $this->af->validate();
40         $this->assertFalse($this->ae->isError('input'));
41         $this->ae->clear();
42
43         $this->af->set('input', 'abc');
44         $this->af->validate();
45         $this->assertTrue($this->ae->isError('input'));
46         $this->ae->clear();
47
48         $this->af->set('input', 'abあ');  // 実質半角4文字
49         $this->af->validate();
50         $this->assertFalse($this->ae->isError('input'));
51         $this->ae->clear();
52
53         //   multibyte.
54         //   内部で強制的にEUC-JPに変換される
55         $this->af->set('input', 'あい');
56         $this->af->validate();
57         $this->assertFalse($this->ae->isError('input'));
58         $this->ae->clear();
59
60         $this->af->set('input', 'あ');
61         $this->af->validate();
62         $this->assertTrue($this->ae->isError('input'));
63         $this->ae->clear();
64
65         $this->af->set('input', 'あいa'); // 実質半角5文字
66         $this->af->validate();
67         $this->assertFalse($this->ae->isError('input'));
68
69         //  TODO: Error Message Test.
70     }
71     // }}}
72 }
73 // }}}
74
75 ?>