-
-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow DotenvFactory to accept an empty array of adapters (#320)
- Loading branch information
1 parent
805c05a
commit 13be13d
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
use Dotenv\Environment\Adapter\EnvConstAdapter; | ||
use Dotenv\Environment\DotenvFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FactoryTest extends TestCase | ||
{ | ||
private static function getAdapters($obj) | ||
{ | ||
$prop = (new ReflectionClass($obj))->getProperty('adapters'); | ||
|
||
$prop->setAccessible(true); | ||
|
||
return $prop->getValue($obj); | ||
} | ||
|
||
public function testDefaults() | ||
{ | ||
$f = new DotenvFactory(); | ||
|
||
$this->assertInstanceOf('Dotenv\Environment\FactoryInterface', $f); | ||
$this->assertCount(3, self::getAdapters($f->create())); | ||
$this->assertCount(3, self::getAdapters($f->createImmutable())); | ||
} | ||
|
||
public function testSingle() | ||
{ | ||
$f = new DotenvFactory([new EnvConstAdapter()]); | ||
|
||
$this->assertInstanceOf('Dotenv\Environment\FactoryInterface', $f); | ||
$this->assertCount(1, self::getAdapters($f->create())); | ||
$this->assertCount(1, self::getAdapters($f->createImmutable())); | ||
} | ||
|
||
public function testNone() | ||
{ | ||
$f = new DotenvFactory([]); | ||
|
||
$this->assertInstanceOf('Dotenv\Environment\FactoryInterface', $f); | ||
$this->assertCount(0, self::getAdapters($f->create())); | ||
$this->assertCount(0, self::getAdapters($f->createImmutable())); | ||
} | ||
} |