From 601aed99c4f0594bf5f304670d8963078f026aba Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 26 Aug 2019 18:03:18 +0200 Subject: [PATCH] Add negatives tests --- tests/Integration/Types/IntegerTypeTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Integration/Types/IntegerTypeTest.php b/tests/Integration/Types/IntegerTypeTest.php index 02b6f5d..f67dade 100644 --- a/tests/Integration/Types/IntegerTypeTest.php +++ b/tests/Integration/Types/IntegerTypeTest.php @@ -12,7 +12,7 @@ public function testNonStringValue() { $this->assertIntegerValidation( 42, 42 ); } - private function assertIntegerValidation( int $expected, $input, array $definitionExtras = [] ) { + private function assertIntegerValidation( $expected, $input, array $definitionExtras = [] ) { $parameters = $this->process( [ 'amount' => array_merge( @@ -35,4 +35,16 @@ public function testNonStringValueDefaultsWhenExceedingUpperBound() { $this->assertIntegerValidation( 7, 42, [ 'upperbound' => 20, 'default' => 7 ] ); } + public function testNonStringDefault() { + $this->assertIntegerValidation( '7', 'NAN', [ 'default' => '7' ] ); + } + + public function testNoNegatives() { + $this->assertIntegerValidation( 7, -1, [ 'negatives' => false, 'default' => 7 ] ); + } + + public function testNegative() { + $this->assertIntegerValidation( -1, -1 ); + } + }