Context
HttpApi constructs its client inline, so the HTTP layer can't be exercised with a fake transport in tests. The graceful failure path (transport/HTTP error → null → Backend "LnBits" unreachable) is only covered indirectly.
src/Invoice/Infrastructure/Http/HttpApi.php — HttpClient::create() is called inside postRequestInvoice(); catches Symfony\Contracts\HttpClient\Exception\ExceptionInterface | JsonException → returns null.
src/Invoice/InvoiceDependencyProvider.php — provides new HttpApi().
Goal
Make HttpApi injectable so its real behavior (success + transport-error → null) can be unit-tested with Symfony's MockHttpClient, with no network.
Scope / Tasks
Implementation notes
symfony/http-client is already a dependency; MockHttpClient ships with it (no new dep).
- Keep the default-construction path so nothing else needs wiring.
Acceptance criteria
Context
HttpApiconstructs its client inline, so the HTTP layer can't be exercised with a fake transport in tests. The graceful failure path (transport/HTTP error →null→Backend "LnBits" unreachable) is only covered indirectly.src/Invoice/Infrastructure/Http/HttpApi.php—HttpClient::create()is called insidepostRequestInvoice(); catchesSymfony\Contracts\HttpClient\Exception\ExceptionInterface | JsonException→ returnsnull.src/Invoice/InvoiceDependencyProvider.php— providesnew HttpApi().Goal
Make
HttpApiinjectable so its real behavior (success + transport-error →null) can be unit-tested with Symfony'sMockHttpClient, with no network.Scope / Tasks
HttpClientInterface $client = null, defaulting toHttpClient::create()(backwards compatible —new HttpApi()still works, andInvoiceDependencyProviderneeds no change).postRequestInvoice().Symfony\Component\HttpClient\MockHttpClient:MockHttpClientthrowing) → returnsnull.null(exercises theExceptionInterface | JsonExceptioncatch).Implementation notes
symfony/http-clientis already a dependency;MockHttpClientships with it (no new dep).Acceptance criteria
HttpApiis constructable with a custom client; default construction unchanged.composer test-allgreen.