Added test

This commit is contained in:
Big Ginger Nerd 2013-10-15 15:01:56 +02:00
parent 89352fcc15
commit da56650a52

View File

@ -623,6 +623,34 @@ class ValidateTest extends BaseTestCase
$v->rule('testRule', 'name', array('foo', 'bar'))->message('Invalid name selected.');
$this->assertFalse($v->validate());
}
public function testBooleanValid()
{
$v = new Validator(array('test' => true));
$v->rule('boolean', 'test');
$this->assertTrue($v->validate());
}
public function testBooleanInvalid()
{
$v = new Validator(array('test' => 'true'));
$v->rule('boolean', 'test');
$this->assertFalse($v->validate());
}
public function testBooleanStringValid()
{
$v = new Validator(array('test' => "true"));
$v->rule('boolean', 'test', true);
$this->assertTrue($v->validate());
}
public function testBooleanStringInvalid()
{
$v = new Validator(array('test' => 'notrue'));
$v->rule('boolean', 'test', true);
$this->assertFalse($v->validate());
}
}
function sampleFunctionCallback($field, $value, array $params) {