2 // vim: foldmethod=marker
4 * ActionForm_Validator_Mbregexp_Test.php
6 * @author Yoshinari Takaoka <takaoka@beatcraft.com>
10 // {{{ Ethna_ActionForm_Validator_Mbregexp_Test
12 * Test Case For Ethna_ActionForm(Mbregexp Validator)
16 class Ethna_ActionForm_Validator_Mbregexp_Test extends Ethna_UnitTestBase
20 $this->af->use_validator_plugin = false;
21 $this->af->clearFormVars();
22 $this->af->form = array();
26 // {{{ Validator Mbregexp.
27 function test_Validate_Regexp()
30 'type' => VAR_TYPE_STRING,
31 'form_type' => FORM_TYPE_TEXT,
33 'mbregexp' => '^[あ-ん]+$',
35 $this->af->setDef('input', $form_def);
37 $this->af->set('input', 'a5A4Pgw9');
38 $this->af->validate();
39 $this->assertTrue($this->ae->isError('input'));
42 $this->af->set('input', 'あいうえおかきくけこ');
43 $this->af->validate();
44 $this->assertFalse($this->ae->isError('input'));
47 $this->af->set('input', 1459);
48 $this->af->validate();
49 $this->assertTrue($this->ae->isError('input'));
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'));