diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index 0c1f41a..cc1c8a6 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -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) {