OSDN Git Service

Merge branch 'release/2.6.0beta2'
[ethna/ethna.git] / test / ActionForm_Validator_Mbregexp_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  ActionForm_Validator_Mbregexp_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 // {{{    Ethna_ActionForm_Validator_Mbregexp_Test
11 /**
12  *  Test Case For Ethna_ActionForm(Mbregexp Validator)
13  *
14  *  @access public
15  */
16 class Ethna_ActionForm_Validator_Mbregexp_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 Mbregexp. 
27     function test_Validate_Regexp()
28     {
29         $form_def = array(
30                         'type' => VAR_TYPE_STRING,
31                         'form_type' => FORM_TYPE_TEXT,
32                         'required' => true,
33                         'mbregexp' => '^[あ-ん]+$',
34                     );        
35         $this->af->setDef('input', $form_def);
36         
37         $this->af->set('input', 'a5A4Pgw9');
38         $this->af->validate();
39         $this->assertTrue($this->ae->isError('input'));
40         $this->ae->clear();
41
42         $this->af->set('input', 'あいうえおかきくけこ');
43         $this->af->validate();
44         $this->assertFalse($this->ae->isError('input'));
45         $this->ae->clear();
46
47         $this->af->set('input', 1459); 
48         $this->af->validate();
49         $this->assertTrue($this->ae->isError('input'));
50         $this->ae->clear();
51
52         //    encoding に指定された文字コード以外の文字列
53         $euc_input = mb_convert_encoding('あいうえお', 'EUC-JP', 'UTF-8');
54         $this->af->set('input', $euc_input);
55         $this->af->validate();
56         $this->assertTrue($this->ae->isError('input'));
57     }
58     // }}}
59 }
60 // }}}
61