mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +09:00
added a test for custom rule xml
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10678 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
914dc85249
commit
72a4d6b0d1
2 changed files with 33 additions and 1 deletions
|
|
@ -117,7 +117,7 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
// regex
|
||||
$vd = new Validator();
|
||||
$customRules['regex_rule']['type'] = 'regex';
|
||||
$customRules['regex_rule']['test'] = '/[a-z]+/';
|
||||
$customRules['regex_rule']['test'] = '/^[a-z]+$/';
|
||||
$vd->addRule($customRules);
|
||||
$vd->addFilter('regex_field', array('rule' => 'regex_rule'));
|
||||
|
||||
|
|
@ -156,6 +156,23 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($vd->validate(array('expr_field' => '15')));
|
||||
}
|
||||
|
||||
public function testCustomRuleXml()
|
||||
{
|
||||
$vd = new Validator(dirname(__FILE__).'/customrule.xml');
|
||||
|
||||
$this->assertTrue($vd->validate(array('regex_field' => 'abc')));
|
||||
$this->assertFalse($vd->validate(array('regex_field' => 'ABC')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field' => 'd')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('enum_field2' => 'a')));
|
||||
$this->assertFalse($vd->validate(array('enum_field2' => 'd')));
|
||||
|
||||
$this->assertTrue($vd->validate(array('expr_field' => '5')));
|
||||
$this->assertFalse($vd->validate(array('expr_field' => '15')));
|
||||
}
|
||||
|
||||
public function testCondition() {
|
||||
$vd = new Validator();
|
||||
$data = array('greeting1'=>'hello');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue