Moving setExpectedException

This commit is contained in:
Vyacheslav Agafonov
2011-12-02 12:25:47 +04:00
parent 1f1551aea1
commit 0fda3de8b5
16 changed files with 38 additions and 29 deletions

View File

@ -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'));
}
}