mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Add a test for name pattern feature
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8997 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
8dfab7ec21
commit
3bfc7e8275
1 changed files with 22 additions and 2 deletions
|
|
@ -30,6 +30,21 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertTrue( $vd->validate() );
|
||||
}
|
||||
|
||||
public function testNamePattern() {
|
||||
$vd = new Validator();
|
||||
$vd->addFilter('^user_', array('length'=>'5:'));
|
||||
|
||||
Context::set('user_123', 'abcd');
|
||||
Context::set('user_456', '123');
|
||||
$this->assertFalse( $vd->validate() );
|
||||
|
||||
Context::set('user_123', 'abcdefg');
|
||||
$this->assertFalse( $vd->validate() );
|
||||
|
||||
Context::set('user_456', '123456');
|
||||
$this->assertTrue( $vd->validate() );
|
||||
}
|
||||
|
||||
public function testDefault() {
|
||||
global $mock_vars;
|
||||
|
||||
|
|
@ -46,8 +61,8 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals( $arr, array('userid'=>'ididid') );
|
||||
|
||||
$arr = array('userid'=>'ownid');
|
||||
$vd->validate(&$arr);
|
||||
$this->assertEquals( $arr, array('userid'=>'ownid') );
|
||||
$vd->validate(&$arr);
|
||||
$this->assertEquals( $arr, array('userid'=>'ownid') );
|
||||
|
||||
// context data
|
||||
$mock_vars = array(); // empty context variables
|
||||
|
|
@ -74,6 +89,8 @@ class ValidatorTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
public function testJSCompile() {
|
||||
$vd = new Validator();
|
||||
$vd->setCacheDir(dirname(__FILE__));
|
||||
}
|
||||
|
||||
public function testCondition() {
|
||||
|
|
@ -150,4 +167,7 @@ class Context
|
|||
public function getLangType() {
|
||||
return 'en';
|
||||
}
|
||||
public function getLang($str) {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue