Passed
Pull Request — master (#180)
by Chema
07:28 queued 03:47
created

FeatureTest::test_load_gacela_dev_file()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\Framework\UsingGacelaFileFromCustomEnv;
6
7
use Gacela\Framework\Gacela;
8
use PHPUnit\Framework\TestCase;
9
10
final class FeatureTest extends TestCase
11
{
12
    public function tearDown(): void
13
    {
14
        # Remove the APP_ENV
15
        putenv('APP_ENV');
16
    }
17
18
    public function test_load_gacela_default_file(): void
19
    {
20
        Gacela::bootstrap(__DIR__);
21
22
        $facade = new LocalConfig\Facade();
23
24
        self::assertSame(
25
            [
26
                'default_key' => 'from:default',
27
                'key' => 'from:default',
28
            ],
29
            $facade->doSomething()
30
        );
31
    }
32
33
    public function test_load_gacela_dev_file(): void
34
    {
35
        putenv('APP_ENV=dev');
36
37
        Gacela::bootstrap(__DIR__);
38
39
        $facade = new LocalConfig\Facade();
40
41
        self::assertSame(
42
            [
43
                'default_key' => 'from:default',
44
                'key' => 'from:dev',
45
            ],
46
            $facade->doSomething()
47
        );
48
    }
49
50
    public function test_load_gacela_prod_file(): void
51
    {
52
        putenv('APP_ENV=prod');
53
54
        Gacela::bootstrap(__DIR__);
55
56
        $facade = new LocalConfig\Facade();
57
58
        self::assertSame(
59
            [
60
                'default_key' => 'from:default',
61
                'key' => 'from:prod',
62
            ],
63
            $facade->doSomething()
64
        );
65
    }
66
67
    public function test_load_gacela_default_file_if_custom_does_not_exists(): void
68
    {
69
        putenv('APP_ENV=custom');
70
71
        Gacela::bootstrap(__DIR__);
72
73
        $facade = new LocalConfig\Facade();
74
75
        self::assertSame(
76
            [
77
                'default_key' => 'from:default',
78
                'key' => 'from:default',
79
            ],
80
            $facade->doSomething()
81
        );
82
    }
83
}
84