|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace PhpLightningTest\Unit\Invoice\Domain\CallbackUrl; |
|
6
|
|
|
|
|
7
|
|
|
use PhpLightning\Http\HttpFacadeInterface; |
|
8
|
|
|
use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface; |
|
9
|
|
|
use PhpLightning\Invoice\Domain\CallbackUrl\CallbackUrl; |
|
10
|
|
|
use PhpLightning\Invoice\Domain\LnAddress\InvoiceGenerator; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
final class CallbackUrlTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function test_get_callback_url(): void |
|
16
|
|
|
{ |
|
17
|
|
|
$invoiceFacade = $this->createStub(BackendInvoiceInterface::class); |
|
18
|
|
|
$invoiceFacade->method('requestInvoice')->willReturn(['status' => 'OK']); |
|
19
|
|
|
|
|
20
|
|
|
$httpFacade = $this->createStub(HttpFacadeInterface::class); |
|
21
|
|
|
|
|
22
|
|
|
$callbackUrl = new CallbackUrl($httpFacade, 'ln@address', 'https://domain/receiver'); |
|
23
|
|
|
|
|
24
|
|
|
self::assertSame([ |
|
25
|
|
|
'callback' => 'https://domain/receiver', |
|
26
|
|
|
'maxSendable' => InvoiceGenerator::MAX_SENDABLE, |
|
27
|
|
|
'minSendable' => InvoiceGenerator::MIN_SENDABLE, |
|
28
|
|
|
'metadata' => json_encode([ |
|
29
|
|
|
['text/plain', 'Pay to ln@address'], |
|
30
|
|
|
['text/identifier', 'ln@address'], |
|
31
|
|
|
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES), |
|
32
|
|
|
'tag' => 'payRequest', |
|
33
|
|
|
'commentAllowed' => false, |
|
34
|
|
|
], $callbackUrl->getCallbackUrl()); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|