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, |
|
|
|
|
43
|
|
|
'max-sendable' => 2_000, |
|
|
|
|
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, |
|
|
|
|
54
|
|
|
'minSendable' => 1_000, |
|
|
|
|
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
|
|
|
|