Passed
Push — master ( 6f6df4...cf3821 )
by Kirill
07:11 queued 03:27
created

LoadTest::testNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Spiral\Tests\DotEnv;
11
12
use PHPUnit\Framework\TestCase;
13
use Spiral\Boot\Directories;
14
use Spiral\Boot\Environment;
15
use Spiral\DotEnv\Bootloader\DotenvBootloader;
16
17
class LoadTest extends TestCase
18
{
19
    public function testNotFound()
20
    {
21
        $e = new Environment();
22
        $d = new Directories(['root' => __DIR__ . '/..']);
23
24
        $b = new DotenvBootloader();
25
        $b->boot($d, $e);
26
27
        $this->assertNull($e->get('KEY'));
28
    }
29
30
    public function testFound()
31
    {
32
        $e = new Environment();
33
        $d = new Directories(['root' => __DIR__]);
34
35
        $b = new DotenvBootloader();
36
        $b->boot($d, $e);
37
38
        $this->assertSame('value', $e->get('KEY'));
39
    }
40
41
    public function testFoundCustom()
42
    {
43
        $e = new Environment([
44
            'DOTENV_PATH' => __DIR__ . '/.env.custom'
45
        ]);
46
47
        $d = new Directories(['root' => __DIR__]);
48
49
        $b = new DotenvBootloader();
50
        $b->boot($d, $e);
51
52
        $this->assertSame('custom_value', $e->get('KEY'));
53
    }
54
}
55