Testing your application
Prelude::fake() swaps the SDK client with one backed by a fake transporter, so your
tests replay queued responses instead of calling the Prelude API.
use AndreaAlhena\PreludeSdkLaravel\Facades\Prelude;
it('verifies the phone number', function () {
$fake = Prelude::fake();
$fake->queueJson([
'id' => 'vrf_01jc0t6fwwfgfsq1md24mhyztj',
'method' => 'message',
'status' => 'success',
]);
// ... code under test calling Prelude::verification()->create(...) ...
$fake->assertSentCount(1);
$fake->assertSent(fn ($request) => str_ends_with($request->getUri()->getPath(), '/v2/verification'));
});
The fake transporter
Prelude::fake() returns a FakeTransporter you can drive and assert on:
| Method | Purpose |
|---|---|
queueJson(array $data, int $status = 200) | Queue a JSON response. |
queue(ResponseInterface $response) | Queue a full PSR-7 response. |
recorded() | Get every request sent, in order. |
assertSent(callable $callback) | Assert a sent request satisfies a predicate. |
assertSentCount(int $count) | Assert the exact number of requests sent. |
assertNothingSent() | Assert no request was sent. |
Because the fake plugs in at the PSR-18 transport layer, your code exercises the real SDK — parameter building, request shaping and response parsing all run — only the network call is replaced.