|
@ -45,12 +45,10 @@ class RegexValidatorTest extends PHPUnit_Framework_TestCase |
|
|
$this->assertEquals('i am ok', $validator->getMessage()); |
|
|
$this->assertEquals('i am ok', $validator->getMessage()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @expectedException GeneralException |
|
|
|
|
|
* @expectedExceptionMessage Message template "regex_not_match" unknown. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
public function testNullMessage() |
|
|
public function testNullMessage() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException', 'Message template "regex_not_match" unknown.'); |
|
|
$validator = new RegexValidator('/a/i'); |
|
|
$validator = new RegexValidator('/a/i'); |
|
|
$validator->setMessage(null, null); |
|
|
$validator->setMessage(null, null); |
|
|
$validator->isValid('1212'); |
|
|
$validator->isValid('1212'); |
|
@ -58,20 +56,17 @@ class RegexValidatorTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @TODO: RegexValidator - wrong regex throws an error. Check this. |
|
|
* @TODO: RegexValidator - wrong regex throws an error. Check this. |
|
|
* @expectedException PHPUnit_Framework_Error |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
public function testWrongRegexp() |
|
|
public function testWrongRegexp() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('PHPUnit_Framework_Error'); |
|
|
$validator = new RegexValidator('/^[a-z][0-9]$*/i'); |
|
|
$validator = new RegexValidator('/^[a-z][0-9]$*/i'); |
|
|
$this->assertFalse($validator->isValid('to423$%ny')); |
|
|
$this->assertFalse($validator->isValid('to423$%ny')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @expectedException GeneralException |
|
|
|
|
|
* @expectedExceptionMessage regex |
|
|
|
|
|
*/ |
|
|
|
|
|
public function testRegexReturnsFalse() |
|
|
public function testRegexReturnsFalse() |
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException', 'regex'); |
|
|
$validator = new RegexValidator('/(?:\D+|<\d+>)*[!?]/'); |
|
|
$validator = new RegexValidator('/(?:\D+|<\d+>)*[!?]/'); |
|
|
$this->assertFalse($validator->isValid('foobar foobar foobar')); |
|
|
$this->assertFalse($validator->isValid('foobar foobar foobar')); |
|
|
} |
|
|
} |