Test Failed
Push — main ( 117601...63d9b1 )
by Chema
11:24
created

CallbackUrlTest::test_get_callback_url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
nc 1
nop 0
dl 0
loc 25
c 1
b 0
f 0
cc 1
rs 9.6333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightningTest\Unit\Invoice\Domain\CallbackUrl;
6
7
use PhpLightning\Invoice\Application\CallbackUrl;
8
use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface;
9
use PhpLightning\Invoice\Domain\CallbackUrl\LnAddressGeneratorInterface;
10
use PhpLightning\Shared\Transfer\BackendInvoiceResponse;
11
use PhpLightning\Shared\Value\SendableRange;
12
use PHPUnit\Framework\TestCase;
13
14
final class CallbackUrlTest extends TestCase
15
{
16
    public function test_get_callback_url(): void
17
    {
18
        $invoiceFacade = $this->createStub(BackendInvoiceInterface::class);
19
        $invoiceFacade->method('requestInvoice')->willReturn(new BackendInvoiceResponse());
20
21
        $lnAddressGenerator = $this->createStub(LnAddressGeneratorInterface::class);
22
        $lnAddressGenerator->method('generate')->willReturn('ln@address');
23
24
        $callbackUrl = new CallbackUrl(
25
            SendableRange::withMinMax(1_000, 5_000),
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting ',' or ')' on line 25 at column 39
Loading history...
26
            $lnAddressGenerator,
27
            'https://domain/receiver',
28
        );
29
30
        self::assertEquals([
31
            'callback' => 'https://domain/receiver',
32
            'minSendable' => 1_000,
33
            'maxSendable' => 5_000,
34
            'metadata' => json_encode([
35
                ['text/plain', 'Pay to ln@address'],
36
                ['text/identifier', 'ln@address'],
37
            ], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES),
38
            'tag' => 'payRequest',
39
            'commentAllowed' => false,
40
        ], $callbackUrl->getCallbackUrl('username'));
41
    }
42
}
43