Passed
Push — main ( 70cc64...daf31f )
by Chema
01:00 queued 13s
created

LightningConfigTest::test_max_sendable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 10
rs 10
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 PHPUnit\Framework\TestCase;
10
11
final class LightningConfigTest extends TestCase
12
{
13
    public function test_default_values(): void
14
    {
15
        $config = new LightningConfig();
16
17
        self::assertSame([
18
            'mode' => 'test',
19
            'backends' => [],
20
        ], $config->jsonSerialize());
21
    }
22
23
    public function test_mode(): void
24
    {
25
        $config = (new LightningConfig())
26
            ->setMode('prod');
27
28
        self::assertSame([
29
            'mode' => 'prod',
30
            'backends' => [],
31
        ], $config->jsonSerialize());
32
    }
33
34
    public function test_domain_with_scheme(): void
35
    {
36
        $config = (new LightningConfig())
37
            ->setDomain('https://your-domain.com');
38
39
        self::assertSame([
40
            'mode' => 'test',
41
            'backends' => [],
42
            'domain' => 'your-domain.com',
43
        ], $config->jsonSerialize());
44
    }
45
46
    public function test_domain_without_scheme(): void
47
    {
48
        $config = (new LightningConfig())
49
            ->setDomain('your-domain.com');
50
51
        self::assertSame([
52
            'mode' => 'test',
53
            'backends' => [],
54
            'domain' => 'your-domain.com',
55
        ], $config->jsonSerialize());
56
    }
57
58
    public function test_receiver(): void
59
    {
60
        $config = (new LightningConfig())
61
            ->setReceiver('custom-receiver');
62
63
        self::assertSame([
64
            'mode' => 'test',
65
            'backends' => [],
66
            'receiver' => 'custom-receiver',
67
        ], $config->jsonSerialize());
68
    }
69
70
    public function test_min_sendable(): void
71
    {
72
        $config = (new LightningConfig())
73
            ->setMinSendable(100_000);
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Unit\Config\100_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
74
75
        self::assertSame([
76
            'mode' => 'test',
77
            'backends' => [],
78
            'min-sendable' => 100_000,
79
        ], $config->jsonSerialize());
80
    }
81
82
    public function test_max_sendable(): void
83
    {
84
        $config = (new LightningConfig())
85
            ->setMaxSendable(10_000_000_000);
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Unit\Config\10_000_000_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
86
87
        self::assertSame([
88
            'mode' => 'test',
89
            'backends' => [],
90
            'max-sendable' => 10_000_000_000,
91
        ], $config->jsonSerialize());
92
    }
93
94
    public function test_ln_bits_backend(): void
95
    {
96
        $config = (new LightningConfig())
97
            ->addBackend(
98
                (new LnBitsBackendConfig())
99
                    ->setApiEndpoint('http://localhost:5000')
100
                    ->setApiKey('XYZ'),
101
            );
102
103
        self::assertSame([
104
            'mode' => 'test',
105
            'backends' => [
106
                'lnbits' => [
107
                    'api_endpoint' => 'http://localhost:5000',
108
                    'api_key' => 'XYZ',
109
                ],
110
            ],
111
        ], $config->jsonSerialize());
112
    }
113
}
114