OSDN Git Service

- followed ini file name changes.
[ethna/ethna.git] / test / Ethna_ActionForm_Validator_Strmax_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_ActionForm_Validator_Strmax_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 // {{{    Ethna_ActionForm_Validator_Strmax_Test
11 /**
12  *  Test Case For Ethna_ActionForm(Max Validator(Single byte String))
13  *
14  *  @access public
15  */
16 class Ethna_ActionForm_Validator_Strmax_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 Max Single byte String. 
27     function test_Validate_SingleByteMax_String()
28     {
29         $form_def = array(
30                           'type'          => VAR_TYPE_STRING,
31                           'form_type'     => FORM_TYPE_TEXT,
32                           'required'      => true,
33                           'strmax'      => '3',
34                     );        
35         $this->af->setDef('input', $form_def);
36         
37         //   in ascii.
38         $this->af->set('input', 'abc'); 
39         $this->af->validate();
40         $this->assertFalse($this->ae->isError('input'));
41         $this->ae->clear();
42
43         $this->af->set('input', 'abcd');
44         $this->af->validate();
45         $this->assertTrue($this->ae->isError('input'));
46         $this->ae->clear();
47
48         $this->af->set('input', 'ab');
49         $this->af->validate();
50         $this->assertFalse($this->ae->isError('input'));
51         $this->ae->clear();
52
53         //   multibyte.
54         $this->af->set('input', 'あいう');
55         $this->af->validate();
56         $this->assertTrue($this->ae->isError('input'));
57         $this->ae->clear();
58
59         //  TODO: Error Message Test.
60     }
61     // }}}
62 }
63 // }}}
64