OSDN Git Service

- message catalog parser is now multiple line parser.
[ethna/ethna.git] / test / Ethna_ActionForm_Validator_Regexp_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_ActionForm_Validator_Regexp_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 // {{{    Ethna_ActionForm_Validator_Regexp_Test
11 /**
12  *  Test Case For Ethna_ActionForm(Regexp Validator)
13  *
14  *  @access public
15  */
16 class Ethna_ActionForm_Validator_Regexp_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 Regexp. 
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                         'regexp' => '/^[A-Za-z0-9]+$/',
34                     );        
35         $this->af->setDef('input', $form_def);
36         
37         $this->af->set('input', 'a5A4Pgw9');
38         $this->af->validate();
39         $this->assertFalse($this->ae->isError('input'));
40         $this->ae->clear();
41
42         $this->af->set('input', '-80pz;+');
43         $this->af->validate();
44         $this->assertTrue($this->ae->isError('input'));
45         $this->ae->clear();
46
47         $this->af->set('input', 1459); 
48         $this->af->validate();
49         $this->assertFalse($this->ae->isError('input'));
50         $this->ae->clear();
51
52         //   regexp はマルチバイトには対応していない
53         $this->af->set('input', 'あいうえお');
54         $this->af->validate();
55         $this->assertTrue($this->ae->isError('input'));
56     }
57     // }}}
58
59 }
60 // }}}
61
62 ?>