2
2
3
3
use Dotenv \Dotenv ;
4
4
5
- class DotenvTest extends \ PHPUnit_Framework_TestCase
5
+ class DotenvTest extends PHPUnit_Framework_TestCase
6
6
{
7
7
/**
8
8
* @var string
9
9
*/
10
10
private $ fixturesFolder ;
11
11
12
- /**
13
- * @var string
14
- */
15
- private $ fixturesFolderWrong ;
16
-
17
12
public function setUp ()
18
13
{
19
14
$ this ->fixturesFolder = dirname (__DIR__ ).'/fixtures/env ' ;
20
- $ this ->fixturesFolderWrong = dirname (__DIR__ ).'/fixtures/env-wrong ' ;
21
15
}
22
16
17
+ /**
18
+ * @expectedException \Dotenv\Exception\InvalidPathException
19
+ * @expectedExceptionMessage Unable to read the environment file at
20
+ */
23
21
public function testDotenvThrowsExceptionIfUnableToLoadFile ()
24
22
{
25
- $ this ->setExpectedException ('InvalidArgumentException ' );
26
-
27
23
$ dotenv = new Dotenv (__DIR__ );
28
24
$ dotenv ->load ();
29
25
}
@@ -64,12 +60,12 @@ public function testQuotedDotenvLoadsEnvironmentVars()
64
60
}
65
61
66
62
/**
67
- * @expectedException InvalidArgumentException
63
+ * @expectedException \Dotenv\Exception\InvalidFileException
68
64
* @expectedExceptionMessage Dotenv values containing spaces must be surrounded by quotes.
69
65
*/
70
66
public function testSpacedValuesWithoutQuotesThrowsException ()
71
67
{
72
- $ dotenv = new Dotenv ($ this -> fixturesFolderWrong , 'spaced-wrong.env ' );
68
+ $ dotenv = new Dotenv (dirname ( __DIR__ ). ' /fixtures/env-wrong ' , 'spaced-wrong.env ' );
73
69
$ dotenv ->load ();
74
70
}
75
71
@@ -156,8 +152,8 @@ public function testDotenvAllowedValues()
156
152
* @depends testDotenvLoadsEnvGlobals
157
153
* @depends testDotenvLoadsServerGlobals
158
154
*
159
- * @expectedException RuntimeException
160
- * @expectedExceptionMessage One or more environment variables failed assertions: FOO is not an allowed value
155
+ * @expectedException \Dotenv\Exception\ValidationException
156
+ * @expectedExceptionMessage One or more environment variables failed assertions: FOO is not an allowed value.
161
157
*/
162
158
public function testDotenvProhibitedValues ()
163
159
{
@@ -167,8 +163,8 @@ public function testDotenvProhibitedValues()
167
163
}
168
164
169
165
/**
170
- * @expectedException RuntimeException
171
- * @expectedExceptionMessage One or more environment variables failed assertions: FOOX is missing, NOPE is missing
166
+ * @expectedException \Dotenv\Exception\ValidationException
167
+ * @expectedExceptionMessage One or more environment variables failed assertions: FOOX is missing, NOPE is missing.
172
168
*/
173
169
public function testDotenvRequiredThrowsRuntimeException ()
174
170
{
@@ -278,8 +274,8 @@ public function testDotenvAssertions()
278
274
}
279
275
280
276
/**
281
- * @expectedException RuntimeException
282
- * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR2 is empty
277
+ * @expectedException \Dotenv\Exception\ValidationException
278
+ * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR2 is empty.
283
279
*/
284
280
public function testDotenvEmptyThrowsRuntimeException ()
285
281
{
@@ -291,8 +287,8 @@ public function testDotenvEmptyThrowsRuntimeException()
291
287
}
292
288
293
289
/**
294
- * @expectedException RuntimeException
295
- * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR3 is empty
290
+ * @expectedException \Dotenv\Exception\ValidationException
291
+ * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR3 is empty.
296
292
*/
297
293
public function testDotenvStringOfSpacesConsideredEmpty ()
298
294
{
@@ -304,8 +300,8 @@ public function testDotenvStringOfSpacesConsideredEmpty()
304
300
}
305
301
306
302
/**
307
- * @expectedException RuntimeException
308
- * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR3 is empty
303
+ * @expectedException \Dotenv\Exception\ValidationException
304
+ * @expectedExceptionMessage One or more environment variables failed assertions: ASSERTVAR3 is empty.
309
305
*/
310
306
public function testDotenvHitsLastChain ()
311
307
{
@@ -315,8 +311,8 @@ public function testDotenvHitsLastChain()
315
311
}
316
312
317
313
/**
318
- * @expectedException RuntimeException
319
- * @expectedExceptionMessage One or more environment variables failed assertions: foo is missing
314
+ * @expectedException \Dotenv\Exception\ValidationException
315
+ * @expectedExceptionMessage One or more environment variables failed assertions: foo is missing.
320
316
*/
321
317
public function testDotenvValidateRequiredWithoutLoading ()
322
318
{
0 commit comments