From 5d0aaf958325f500ce69cfb79e69eb0d8f83fdeb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 28 Jun 2012 17:17:24 +0200 Subject: treat empty string inputs as unset for int and bool --- _test/tests/inc/input.test.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 627af3a2b..761b7ddbc 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -95,6 +95,11 @@ class input_test extends DokuWikiTest { $this->assertSame(1, $INPUT->get->int('get', false)); $this->assertSame(0, $INPUT->int('array')); + + $this->assertSame(0, $INPUT->int('zero', -1)); + $this->assertSame(-1, $INPUT->int('empty', -1)); + $this->assertSame(-1, $INPUT->int('zero', -1, true)); + $this->assertSame(-1, $INPUT->int('empty', -1, true)); } public function test_arr() { @@ -155,6 +160,11 @@ class input_test extends DokuWikiTest { $this->assertSame(false, $INPUT->post->bool('get')); $this->assertSame(true, $INPUT->post->bool('post')); + + $this->assertSame(false, $INPUT->bool('zero', -1)); + $this->assertSame(-1, $INPUT->bool('empty', -1)); + $this->assertSame(-1, $INPUT->bool('zero', -1, true)); + $this->assertSame(-1, $INPUT->bool('empty', -1, true)); } public function test_remove() { @@ -203,4 +213,4 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } -} \ No newline at end of file +} -- cgit v1.2.3