diff --git a/tests/Dotenv/ValidatorBooleanTest.php b/tests/Dotenv/ValidatorBooleanTest.php index 6896df62..5a4c875a 100644 --- a/tests/Dotenv/ValidatorBooleanTest.php +++ b/tests/Dotenv/ValidatorBooleanTest.php @@ -84,7 +84,7 @@ public function invalidBooleanValuesDataProvider() /** * @dataProvider invalidBooleanValuesDataProvider - * @expectedException Dotenv\Exception\ValidationException + * @expectedException \Dotenv\Exception\ValidationException * @expectedExceptionMessage One or more environment variables failed assertions: INVALID_ */ public function testCanInvalidateNonBooleans($boolean) diff --git a/tests/Dotenv/ValidatorIntegerTest.php b/tests/Dotenv/ValidatorIntegerTest.php new file mode 100644 index 00000000..77b8eac9 --- /dev/null +++ b/tests/Dotenv/ValidatorIntegerTest.php @@ -0,0 +1,81 @@ +fixturesFolder = dirname(__DIR__).'/fixtures/env'; + } + + /** + * List of valid integer values in fixtures/env/integers.env. + * + * @return array + */ + public function validIntegerValuesDataProvider() + { + return [ + ['VALID_ZERO'], + ['VALID_ONE'], + ['VALID_TWO'], + + ['VALID_LARGE'], + ['VALID_HUGE'], + ]; + } + + /** + * @dataProvider validIntegerValuesDataProvider + */ + public function testCanValidateIntegers($integer) + { + $dotenv = Dotenv::create($this->fixturesFolder, 'integers.env'); + $dotenv->load(); + + $dotenv->required($integer)->isInteger(); + + $this->assertTrue(true); // anything wrong - an exception will be thrown + } + + /** + * List of non-integer values in fixtures/env/integers.env. + * + * @return array + */ + public function invalidIntegerValuesDataProvider() + { + return [ + ['INVALID_SOMETHING'], + ['INVALID_EMPTY'], + ['INVALID_EMPTY_STRING'], + ['INVALID_NULL'], + ['INVALID_NEGATIVE'], + ['INVALID_MINUS'], + ['INVALID_TILDA'], + ['INVALID_EXCLAMATION'], + ['INVALID_SPACES'], + ['INVALID_COMMAS'], + ]; + } + + /** + * @dataProvider invalidIntegerValuesDataProvider + * @expectedException \Dotenv\Exception\ValidationException + * @expectedExceptionMessage One or more environment variables failed assertions: INVALID_ + */ + public function testCanInvalidateNonIntegers($integer) + { + $dotenv = Dotenv::create($this->fixturesFolder, 'integers.env'); + $dotenv->load(); + + $dotenv->required($integer)->isInteger(); + } +} diff --git a/tests/fixtures/env/integers.env b/tests/fixtures/env/integers.env new file mode 100644 index 00000000..4895efc7 --- /dev/null +++ b/tests/fixtures/env/integers.env @@ -0,0 +1,17 @@ +VALID_ZERO=0 +VALID_ONE=1 +VALID_TWO=2 + +VALID_LARGE=99999999 +VALID_HUGE=99999999999999999999999999999999 + +INVALID_SOMETHING=something +INVALID_EMPTY= +INVALID_EMPTY_STRING="" +INVALID_NULL=null +INVALID_NEGATIVE=-2 +INVALID_MINUS=- +INVALID_TILDA=~ +INVALID_EXCLAMATION=! +INVALID_SPACES=" 123" +INVALID_COMMAS="123,123"