Passed
Pull Request — main (#3)
by Chema
02:25
created

CallbackUrlTest::test_get_callback_url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 20
rs 9.7666
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