Moving setExpectedException
This commit is contained in:
@ -26,8 +26,8 @@ class EqualValidatorTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testNullToken()
|
||||
{
|
||||
$this->setExpectedException('InitializationException','Token not defined');
|
||||
$validator = new EqualValidator(null);
|
||||
$this->setExpectedException('InitializationException','Token not defined');
|
||||
$validator->isValid('not token');
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,11 @@ class RegexValidatorTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testNullMessage()
|
||||
{
|
||||
$this->setExpectedException('GeneralException', 'Message template "regex_not_match" unknown.');
|
||||
$validator = new RegexValidator('/a/i');
|
||||
$validator->setMessage(null, null);
|
||||
|
||||
$this->setExpectedException('GeneralException', 'Message template "regex_not_match" unknown.');
|
||||
|
||||
$validator->isValid('1212');
|
||||
}
|
||||
|
||||
@ -59,15 +61,15 @@ class RegexValidatorTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWrongRegexp()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
$validator = new RegexValidator('/^[a-z][0-9]$*/i');
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
$this->assertFalse($validator->isValid('to423$%ny'));
|
||||
}
|
||||
|
||||
public function testRegexReturnsFalse()
|
||||
{
|
||||
$this->setExpectedException('GeneralException', 'regex');
|
||||
$validator = new RegexValidator('/(?:\D+|<\d+>)*[!?]/');
|
||||
$this->setExpectedException('GeneralException', 'regex');
|
||||
$this->assertFalse($validator->isValid('foobar foobar foobar'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user