File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,36 @@ public function testCanValidateBooleans($boolean)
60
60
61
61
$ this ->assertTrue (true ); // anything wrong - an exception will be thrown
62
62
}
63
+
64
+ /**
65
+ * List of non-boolean values in fixtures/env/booleans.env
66
+ *
67
+ * @return array
68
+ */
69
+ public function invalidBooleanValuesDataProvider ()
70
+ {
71
+ return [
72
+ ['INVALID_SOMETHING ' ],
73
+ ['INVALID_EMPTY ' ],
74
+ ['INVALID_EMPTY_STRING ' ],
75
+ ['INVALID_NULL ' ],
76
+ ['INVALID_NUMBER_POSITIVE ' ],
77
+ ['INVALID_NUMBER_NEGATIVE ' ],
78
+ ['INVALID_MINUS ' ],
79
+ ['INVALID_TILDA ' ],
80
+ ['INVALID_EXCLAMATION ' ],
81
+ ];
82
+ }
83
+
84
+ /**
85
+ * @dataProvider invalidBooleanValuesDataProvider
86
+ * @expectedException Dotenv\Exception\ValidationException
87
+ */
88
+ public function testCanInvalidateNonBooleans ($ boolean )
89
+ {
90
+ $ dotenv = new Dotenv ($ this ->fixturesFolder , 'booleans.env ' );
91
+ $ dotenv ->load ();
92
+
93
+ $ dotenv ->required ($ boolean )->isBoolean ();
94
+ }
63
95
}
Original file line number Diff line number Diff line change @@ -21,3 +21,13 @@ VALID_YESNO_UPPERCASE_TRUE=YES
21
21
VALID_YESNO_UPPERCASE_FALSE = NO
22
22
VALID_YESNO_MIXEDCASE_TRUE = Yes
23
23
VALID_YESNO_MIXEDCASE_FALSE = No
24
+
25
+ INVALID_SOMETHING = something
26
+ INVALID_EMPTY =
27
+ INVALID_EMPTY_STRING = " "
28
+ INVALID_NULL = null
29
+ INVALID_NUMBER_POSITIVE = 2
30
+ INVALID_NUMBER_NEGATIVE = -2
31
+ INVALID_MINUS = -
32
+ INVALID_TILDA = ~
33
+ INVALID_EXCLAMATION = !
You can’t perform that action at this time.
0 commit comments