2 // vim: foldmethod=marker
4 * Ethna_ActionForm_Validator_Regexp_Test.php
6 * @author Yoshinari Takaoka <takaoka@beatcraft.com>
10 // {{{ Ethna_ActionForm_Validator_Regexp_Test
12 * Test Case For Ethna_ActionForm(Regexp Validator)
16 class Ethna_ActionForm_Validator_Regexp_Test extends Ethna_UnitTestBase
20 $this->af->use_validator_plugin = false;
21 $this->af->clearFormVars();
22 $this->af->form = array();
26 // {{{ Validator Regexp.
27 function test_Validate_Regexp()
30 'type' => VAR_TYPE_STRING,
31 'form_type' => FORM_TYPE_TEXT,
33 'regexp' => '/^[A-Za-z0-9]+$/',
35 $this->af->setDef('input', $form_def);
37 $this->af->set('input', 'a5A4Pgw9');
38 $this->af->validate();
39 $this->assertFalse($this->ae->isError('input'));
42 $this->af->set('input', '-80pz;+');
43 $this->af->validate();
44 $this->assertTrue($this->ae->isError('input'));
47 $this->af->set('input', 1459);
48 $this->af->validate();
49 $this->assertFalse($this->ae->isError('input'));
52 // regexp はマルチバイトには対応していない
53 $this->af->set('input', 'あいうえお');
54 $this->af->validate();
55 $this->assertTrue($this->ae->isError('input'));