Skip to content

Commit 719eaff

Browse files
Cleaned up tests
1 parent e706e25 commit 719eaff

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

tests/Dotenv/DotenvTest.php

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,24 @@
22

33
use Dotenv\Dotenv;
44

5-
class DotenvTest extends \PHPUnit_Framework_TestCase
5+
class DotenvTest extends PHPUnit_Framework_TestCase
66
{
77
/**
88
* @var string
99
*/
1010
private $fixturesFolder;
1111

12-
/**
13-
* @var string
14-
*/
15-
private $fixturesFolderWrong;
16-
1712
public function setUp()
1813
{
1914
$this->fixturesFolder = dirname(__DIR__).'/fixtures/env';
20-
$this->fixturesFolderWrong = dirname(__DIR__).'/fixtures/env-wrong';
2115
}
2216

17+
/**
18+
* @expectedException \Dotenv\Exception\InvalidPathException
19+
* @expectedExceptionMessage Unable to read the environment file at
20+
*/
2321
public function testDotenvThrowsExceptionIfUnableToLoadFile()
2422
{
25-
$this->setExpectedException('InvalidArgumentException');
26-
2723
$dotenv = new Dotenv(__DIR__);
2824
$dotenv->load();
2925
}
@@ -64,12 +60,12 @@ public function testQuotedDotenvLoadsEnvironmentVars()
6460
}
6561

6662
/**
67-
* @expectedException InvalidArgumentException
63+
* @expectedException \Dotenv\Exception\InvalidFileException
6864
* @expectedExceptionMessage Dotenv values containing spaces must be surrounded by quotes.
6965
*/
7066
public function testSpacedValuesWithoutQuotesThrowsException()
7167
{
72-
$dotenv = new Dotenv($this->fixturesFolderWrong, 'spaced-wrong.env');
68+
$dotenv = new Dotenv(dirname(__DIR__).'/fixtures/env-wrong', 'spaced-wrong.env');
7369
$dotenv->load();
7470
}
7571

@@ -156,8 +152,8 @@ public function testDotenvAllowedValues()
156152
* @depends testDotenvLoadsEnvGlobals
157153
* @depends testDotenvLoadsServerGlobals
158154
*
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.
161157
*/
162158
public function testDotenvProhibitedValues()
163159
{
@@ -167,8 +163,8 @@ public function testDotenvProhibitedValues()
167163
}
168164

169165
/**
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.
172168
*/
173169
public function testDotenvRequiredThrowsRuntimeException()
174170
{
@@ -278,8 +274,8 @@ public function testDotenvAssertions()
278274
}
279275

280276
/**
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.
283279
*/
284280
public function testDotenvEmptyThrowsRuntimeException()
285281
{
@@ -291,8 +287,8 @@ public function testDotenvEmptyThrowsRuntimeException()
291287
}
292288

293289
/**
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.
296292
*/
297293
public function testDotenvStringOfSpacesConsideredEmpty()
298294
{
@@ -304,8 +300,8 @@ public function testDotenvStringOfSpacesConsideredEmpty()
304300
}
305301

306302
/**
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.
309305
*/
310306
public function testDotenvHitsLastChain()
311307
{
@@ -315,8 +311,8 @@ public function testDotenvHitsLastChain()
315311
}
316312

317313
/**
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.
320316
*/
321317
public function testDotenvValidateRequiredWithoutLoading()
322318
{

tests/Dotenv/LoaderTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
use Dotenv\Loader;
44

5-
class LoaderTest extends \PHPUnit_Framework_TestCase
5+
class LoaderTest extends PHPUnit_Framework_TestCase
66
{
77
public function setUp()
88
{
9-
$this->fixturesFolder = dirname(__DIR__) . '/fixtures/env';
10-
$this->fixturesFolderWrong = dirname(__DIR__) . '/fixtures/env-wrong';
9+
$folder = dirname(__DIR__) . '/fixtures/env';
1110

1211
// Generate a new, random keyVal.
1312
$this->keyVal(true);
1413

1514
// Build an immutable and mutable loader for convenience.
16-
$this->mutableLoader = new Loader($this->fixturesFolder);
17-
$this->immutableLoader = new Loader($this->fixturesFolder, true);
15+
$this->mutableLoader = new Loader($folder);
16+
$this->immutableLoader = new Loader($folder, true);
1817
}
1918

2019
protected $keyVal;

0 commit comments

Comments
 (0)