Passed
Push — attributes ( b566ac...704868 )
by Peter
03:02
created

testMustGetThrowsExceptionIfEnvironmentVariableAndDefaultAreMissing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Config;
6
7
use PHPUnit\Framework\TestCase;
8
9
class ConfigTest extends TestCase
10
{
11
    private const CATEGORY = "FOO";
12
    private const SETTING  = "BAR01";
13
14
    public function testMustGetGetsDefaultIfEnvironmentVariableIsMissing(): void
15
    {
16
        $value = 17;
17
18
        $this->assertEquals($value, Config::mustGet(static::CATEGORY, static::SETTING, $value));
19
    }
20
21
    public function testMustGetGetsEnvironmentVariableValueByDefault(): void
22
    {
23
        $value = 17;
24
        $wrong = "BARBAZ002";
25
26
        Config::set(static::CATEGORY, static::SETTING, $value);
27
28
        $this->assertEquals($value, Config::mustGet(static::CATEGORY, static::SETTING, $wrong));
29
    }
30
31
    public function testMustGetThrowsExceptionIfEnvironmentVariableAndDefaultAreMissing(): void
32
    {
33
        Config::set(static::CATEGORY, static::SETTING, null);
34
35
        $this->expectException(\RuntimeException::class);
36
37
        Config::mustGet(static::CATEGORY, static::SETTING);
38
    }
39
}
40