From da56650a52cf02c0ccf65e60ff5ade33b3cf4921 Mon Sep 17 00:00:00 2001 From: Big Ginger Nerd Date: Tue, 15 Oct 2013 15:01:56 +0200 Subject: [PATCH] Added test --- tests/Valitron/ValidateTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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) {