File tree Expand file tree Collapse file tree 3 files changed +99
-1
lines changed Expand file tree Collapse file tree 3 files changed +99
-1
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public function invalidBooleanValuesDataProvider()
84
84
85
85
/**
86
86
* @dataProvider invalidBooleanValuesDataProvider
87
- * @expectedException Dotenv\Exception\ValidationException
87
+ * @expectedException \ Dotenv\Exception\ValidationException
88
88
* @expectedExceptionMessage One or more environment variables failed assertions: INVALID_
89
89
*/
90
90
public function testCanInvalidateNonBooleans ($ boolean )
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Dotenv \Dotenv ;
4
+ use PHPUnit \Framework \TestCase ;
5
+
6
+ class ValidatorIntegerTest extends TestCase
7
+ {
8
+ /**
9
+ * @var string
10
+ */
11
+ private $ fixturesFolder ;
12
+
13
+ public function setUp ()
14
+ {
15
+ $ this ->fixturesFolder = dirname (__DIR__ ).'/fixtures/env ' ;
16
+ }
17
+
18
+ /**
19
+ * List of valid integer values in fixtures/env/integers.env.
20
+ *
21
+ * @return array
22
+ */
23
+ public function validIntegerValuesDataProvider ()
24
+ {
25
+ return [
26
+ ['VALID_ZERO ' ],
27
+ ['VALID_ONE ' ],
28
+ ['VALID_TWO ' ],
29
+
30
+ ['VALID_LARGE ' ],
31
+ ['VALID_HUGE ' ],
32
+ ];
33
+ }
34
+
35
+ /**
36
+ * @dataProvider validIntegerValuesDataProvider
37
+ */
38
+ public function testCanValidateIntegers ($ integer )
39
+ {
40
+ $ dotenv = Dotenv::create ($ this ->fixturesFolder , 'integers.env ' );
41
+ $ dotenv ->load ();
42
+
43
+ $ dotenv ->required ($ integer )->isInteger ();
44
+
45
+ $ this ->assertTrue (true ); // anything wrong - an exception will be thrown
46
+ }
47
+
48
+ /**
49
+ * List of non-integer values in fixtures/env/integers.env.
50
+ *
51
+ * @return array
52
+ */
53
+ public function invalidIntegerValuesDataProvider ()
54
+ {
55
+ return [
56
+ ['INVALID_SOMETHING ' ],
57
+ ['INVALID_EMPTY ' ],
58
+ ['INVALID_EMPTY_STRING ' ],
59
+ ['INVALID_NULL ' ],
60
+ ['INVALID_NEGATIVE ' ],
61
+ ['INVALID_MINUS ' ],
62
+ ['INVALID_TILDA ' ],
63
+ ['INVALID_EXCLAMATION ' ],
64
+ ['INVALID_SPACES ' ],
65
+ ['INVALID_COMMAS ' ],
66
+ ];
67
+ }
68
+
69
+ /**
70
+ * @dataProvider invalidIntegerValuesDataProvider
71
+ * @expectedException \Dotenv\Exception\ValidationException
72
+ * @expectedExceptionMessage One or more environment variables failed assertions: INVALID_
73
+ */
74
+ public function testCanInvalidateNonIntegers ($ integer )
75
+ {
76
+ $ dotenv = Dotenv::create ($ this ->fixturesFolder , 'integers.env ' );
77
+ $ dotenv ->load ();
78
+
79
+ $ dotenv ->required ($ integer )->isInteger ();
80
+ }
81
+ }
Original file line number Diff line number Diff line change
1
+ VALID_ZERO = 0
2
+ VALID_ONE = 1
3
+ VALID_TWO = 2
4
+
5
+ VALID_LARGE = 99999999
6
+ VALID_HUGE = 99999999999999999999999999999999
7
+
8
+ INVALID_SOMETHING = something
9
+ INVALID_EMPTY =
10
+ INVALID_EMPTY_STRING = " "
11
+ INVALID_NULL = null
12
+ INVALID_NEGATIVE = -2
13
+ INVALID_MINUS = -
14
+ INVALID_TILDA = ~
15
+ INVALID_EXCLAMATION = !
16
+ INVALID_SPACES = " 123"
17
+ INVALID_COMMAS = " 123,123"
You can’t perform that action at this time.
0 commit comments