php-lightning /
lnaddress
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace PhpLightningTest\Unit\Config; |
||
| 6 | |||
| 7 | use PhpLightning\Config\LightningConfig; |
||
| 8 | use PhpLightning\Shared\Value\SendableRange; |
||
| 9 | use PHPUnit\Framework\TestCase; |
||
| 10 | |||
| 11 | final class LightningConfigTest extends TestCase |
||
| 12 | { |
||
| 13 | public function test_default_values(): void |
||
| 14 | { |
||
| 15 | $config = new LightningConfig(); |
||
| 16 | |||
| 17 | self::assertSame([], $config->jsonSerialize()); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function test_domain_with_scheme(): void |
||
| 21 | { |
||
| 22 | $config = (new LightningConfig()) |
||
| 23 | ->setDomain('https://your-domain.com'); |
||
| 24 | |||
| 25 | self::assertSame([ |
||
| 26 | 'domain' => 'your-domain.com', |
||
| 27 | ], $config->jsonSerialize()); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function test_domain_without_scheme(): void |
||
| 31 | { |
||
| 32 | $config = (new LightningConfig()) |
||
| 33 | ->setDomain('your-domain.com'); |
||
| 34 | |||
| 35 | self::assertSame([ |
||
| 36 | 'domain' => 'your-domain.com', |
||
| 37 | ], $config->jsonSerialize()); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function test_receiver(): void |
||
| 41 | { |
||
| 42 | $config = (new LightningConfig()) |
||
| 43 | ->setReceiver('custom-receiver'); |
||
| 44 | |||
| 45 | self::assertSame([ |
||
| 46 | 'receiver' => 'custom-receiver', |
||
| 47 | ], $config->jsonSerialize()); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function test_sendable_range(): void |
||
| 51 | { |
||
| 52 | $config = (new LightningConfig()) |
||
| 53 | ->setSendableRange(1_000, 5_000); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 54 | |||
| 55 | self::assertEquals([ |
||
| 56 | 'sendable-range' => SendableRange::withMinMax(1_000, 5_000), |
||
| 57 | ], $config->jsonSerialize()); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function test_description_and_success_message(): void |
||
| 61 | { |
||
| 62 | $config = (new LightningConfig()) |
||
| 63 | ->setDescriptionTemplate('Pay to %s on example') |
||
| 64 | ->setSuccessMessage('Thanks!'); |
||
| 65 | |||
| 66 | self::assertSame([ |
||
| 67 | 'description-template' => 'Pay to %s on example', |
||
| 68 | 'success-message' => 'Thanks!', |
||
| 69 | ], $config->jsonSerialize()); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |