|
1 | 1 | <?php
|
2 | 2 |
|
3 | 3 | use Dotenv\Dotenv;
|
| 4 | +use Dotenv\Loader\Loader; |
| 5 | +use Dotenv\Repository\RepositoryBuilder; |
| 6 | +use Dotenv\Store\StoreBuilder; |
4 | 7 | use PHPUnit\Framework\TestCase;
|
5 | 8 |
|
6 | 9 | class DotenvTest extends TestCase
|
@@ -267,10 +270,34 @@ public function testMutlilineLoading()
|
267 | 270 | $this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQS'));
|
268 | 271 | }
|
269 | 272 |
|
270 |
| - public function testGetEnvironmentVariablesList() |
| 273 | + public function testLegacyConstructor() |
271 | 274 | {
|
272 |
| - $dotenv = Dotenv::createImmutable($this->folder); |
273 |
| - $names = array_keys($dotenv->load()); |
274 |
| - $this->assertSame(['FOO', 'BAR', 'SPACED', 'NULL'], $names); |
| 275 | + $loader = new Loader(); |
| 276 | + $repository = RepositoryBuilder::create()->immutable()->make(); |
| 277 | + |
| 278 | + $dotenv = new Dotenv($loader, $repository, [$this->folder.DIRECTORY_SEPARATOR.'.env']); |
| 279 | + |
| 280 | + $this->assertSame([ |
| 281 | + 'FOO' => 'bar', |
| 282 | + 'BAR' => 'baz', |
| 283 | + 'SPACED' => 'with spaces', |
| 284 | + 'NULL' => '', |
| 285 | + ], $dotenv->load()); |
| 286 | + } |
| 287 | + |
| 288 | + public function testLatestConstructor() |
| 289 | + { |
| 290 | + $loader = new Loader(); |
| 291 | + $repository = RepositoryBuilder::create()->immutable()->make(); |
| 292 | + $store = StoreBuilder::create()->withPaths($this->folder)->make(); |
| 293 | + |
| 294 | + $dotenv = new Dotenv($loader, $repository, $store); |
| 295 | + |
| 296 | + $this->assertSame([ |
| 297 | + 'FOO' => 'bar', |
| 298 | + 'BAR' => 'baz', |
| 299 | + 'SPACED' => 'with spaces', |
| 300 | + 'NULL' => '', |
| 301 | + ], $dotenv->load()); |
275 | 302 | }
|
276 | 303 | }
|
0 commit comments