Passed
Push — main ( a1c31e...3240e3 )
by Chema
02:34
created

LightningConfigTest::test_sendable_range()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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_domain_with_scheme(): void
22
    {
23
        $config = (new LightningConfig())
24
            ->setDomain('https://your-domain.com');
25
26
        self::assertSame([
27
            'domain' => 'your-domain.com',
28
        ], $config->jsonSerialize());
29
    }
30
31
    public function test_domain_without_scheme(): void
32
    {
33
        $config = (new LightningConfig())
34
            ->setDomain('your-domain.com');
35
36
        self::assertSame([
37
            'domain' => 'your-domain.com',
38
        ], $config->jsonSerialize());
39
    }
40
41
    public function test_receiver(): void
42
    {
43
        $config = (new LightningConfig())
44
            ->setReceiver('custom-receiver');
45
46
        self::assertSame([
47
            'receiver' => 'custom-receiver',
48
        ], $config->jsonSerialize());
49
    }
50
51
    public function test_sendable_range(): void
52
    {
53
        $config = (new LightningConfig())
54
            ->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...
55
56
        self::assertEquals([
57
            'sendable-range' => SendableRange::withMinMax(1_000, 5_000),
58
        ], $config->jsonSerialize());
59
    }
60
61
    public function test_ln_bits_backend(): void
62
    {
63
        $config = (new LightningConfig())
64
            ->addBackend(
65
                (new LnBitsBackendConfig())
66
                    ->setApiEndpoint('http://localhost:5000')
67
                    ->setApiKey('XYZ'),
68
            );
69
70
        self::assertEquals([
71
            'backends' => [
72
                'lnbits' => [
73
                    'api_endpoint' => 'http://localhost:5000',
74
                    'api_key' => 'XYZ',
75
                ],
76
            ],
77
        ], $config->jsonSerialize());
78
    }
79
}
80