Passed
Push — main ( 3b8d3e...36fa87 )
by Chema
01:12 queued 13s
created

GetCallbackUrlFeature   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
c 0
b 0
f 0
dl 0
loc 46
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_default_values() 0 18 1
A test_custom_config_values() 0 24 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightningTest\Feature;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\Gacela;
9
use PhpLightning\Invoice\Infrastructure\Command\CallbackUrlCommand;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\Console\Tester\CommandTester;
12
13
final class GetCallbackUrlFeature extends TestCase
14
{
15
    public function test_default_values(): void
16
    {
17
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
18
            $config->resetInMemoryCache();
19
        });
20
21
        $tester = new CommandTester(new CallbackUrlCommand());
22
        $tester->execute([]);
23
        $outputAsJson = json_decode($tester->getDisplay(), true);
24
25
        self::assertEquals([
26
            'callback' => 'https://localhost/unknown-receiver',
27
            'maxSendable' => 10000000000,
28
            'minSendable' => 100000,
29
            'metadata' => '[["text/plain","Pay to unknown-receiver@localhost"],["text/identifier","unknown-receiver@localhost"]]',
30
            'tag' => 'payRequest',
31
            'commentAllowed' => false,
32
        ], $outputAsJson);
33
    }
34
35
    public function test_custom_config_values(): void
36
    {
37
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
38
            $config->resetInMemoryCache();
39
            $config->addAppConfigKeyValues([
40
                'domain' => 'custom-domain',
41
                'receiver' => 'custom-receiver',
42
                'min-sendable' => 1_000,
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Feature\1_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
43
                'max-sendable' => 2_000,
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Feature\2_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
            ]);
45
        });
46
47
        $tester = new CommandTester(new CallbackUrlCommand());
48
        $tester->execute([]);
49
        $outputAsJson = json_decode($tester->getDisplay(), true);
50
51
        self::assertEquals([
52
            'callback' => 'https://custom-domain/custom-receiver',
53
            'maxSendable' => 2_000,
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Feature\2_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
54
            'minSendable' => 1_000,
0 ignored issues
show
Bug introduced by
The constant PhpLightningTest\Feature\1_000 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
            'metadata' => '[["text/plain","Pay to custom-receiver@custom-domain"],["text/identifier","custom-receiver@custom-domain"]]',
56
            'tag' => 'payRequest',
57
            'commentAllowed' => false,
58
        ], $outputAsJson);
59
    }
60
}
61