Passed
Pull Request — main (#11)
by Jesús
02:37
created

LightningConfigTest::test_domain_with_scheme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightningTest\Unit\Config;
6
7
use PhpLightning\Config\Backend\LnBitsBackendConfig;
8
use PhpLightning\Config\LightningConfig;
9
use PhpLightning\Shared\Value\SendableRange;
10
use PHPUnit\Framework\TestCase;
11
12
final class LightningConfigTest extends TestCase
13
{
14
    public function test_default_values(): void
15
    {
16
        $config = new LightningConfig();
17
18
        self::assertSame([], $config->jsonSerialize());
19
    }
20
21
    public function test_mode(): void
22
    {
23
        $config = (new LightningConfig())
24
            ->setMode('test');
25
26
        self::assertSame([
27
            'mode' => 'test',
28
        ], $config->jsonSerialize());
29
    }
30
31
    public function test_domain_with_scheme(): void
32
    {
33
        $config = (new LightningConfig())
34
            ->setDomain('https://your-domain.com');
35
36
        self::assertSame([
37
            'domain' => 'your-domain.com',
38
        ], $config->jsonSerialize());
39
    }
40
41
    public function test_domain_without_scheme(): void
42
    {
43
        $config = (new LightningConfig())
44
            ->setDomain('your-domain.com');
45
46
        self::assertSame([
47
            'domain' => 'your-domain.com',
48
        ], $config->jsonSerialize());
49
    }
50
51
    public function test_receiver(): void
52
    {
53
        $config = (new LightningConfig())
54
            ->setReceiver('custom-receiver');
55
56
        self::assertSame([
57
            'receiver' => 'custom-receiver',
58
        ], $config->jsonSerialize());
59
    }
60
61
    public function test_sendable_range(): void
62
    {
63
        $config = (new LightningConfig())
64
            ->setSendableRange(1_000, 5_000);
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Unit\Config\1_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant PhpLightningTest\Unit\Config\5_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
65
66
        self::assertEquals([
67
            'sendable-range' => SendableRange::withMinMax(1_000, 5_000),
68
        ], $config->jsonSerialize());
69
    }
70
71
    public function test_ln_bits_backend(): void
72
    {
73
        $config = (new LightningConfig())
74
            ->addBackend(
75
                (new LnBitsBackendConfig())
76
                    ->setApiEndpoint('http://localhost:5000')
77
                    ->setApiKey('XYZ'),
78
            );
79
80
        self::assertEquals([
81
            'backends' => [
82
                'lnbits' => [
83
                    'api_endpoint' => 'http://localhost:5000',
84
                    'api_key' => 'XYZ',
85
                ],
86
            ],
87
        ], $config->jsonSerialize());
88
    }
89
}
90