Passed
Push — feature/reset-cache-from-abstr... ( a5e9c2...ccf444 )
by Jesús
03:46 queued 36s
created

FeatureTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_load_config_from_custom_env_dev() 0 15 1
A test_load_config_from_custom_env_default() 0 13 1
A test_load_config_from_custom_env_prod() 0 15 1
A tearDown() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\Framework\UsingConfigFromCustomEnv;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\Gacela;
9
use PHPUnit\Framework\TestCase;
10
11
final class FeatureTest extends TestCase
12
{
13
    public function tearDown(): void
14
    {
15
        # Remove the APP_ENV
16
        putenv('APP_ENV');
17
    }
18
19
    public function test_load_config_from_custom_env_default(): void
20
    {
21
        Gacela::bootstrap(__DIR__, GacelaConfig::withPhpConfigDefault());
22
23
        $facade = new LocalConfig\Facade();
24
25
        self::assertSame(
26
            [
27
                'from-default' => 1,
28
                'from-default-env-override' => 1,
29
                'from-local-override' => 4,
30
            ],
31
            $facade->doSomething()
32
        );
33
    }
34
35
    public function test_load_config_from_custom_env_dev(): void
36
    {
37
        putenv('APP_ENV=dev');
38
39
        Gacela::bootstrap(__DIR__, GacelaConfig::withPhpConfigDefault());
40
41
        $facade = new LocalConfig\Facade();
42
43
        self::assertSame(
44
            [
45
                'from-default' => 1,
46
                'from-default-env-override' => 2,
47
                'from-local-override' => 4,
48
            ],
49
            $facade->doSomething()
50
        );
51
    }
52
53
    public function test_load_config_from_custom_env_prod(): void
54
    {
55
        putenv('APP_ENV=prod');
56
57
        Gacela::bootstrap(__DIR__, GacelaConfig::withPhpConfigDefault());
58
59
        $facade = new LocalConfig\Facade();
60
61
        self::assertSame(
62
            [
63
                'from-default' => 1,
64
                'from-default-env-override' => 3,
65
                'from-local-override' => 4,
66
            ],
67
            $facade->doSomething()
68
        );
69
    }
70
}
71