Faking
Swap the live JSON-RPC client with an in-memory fake so tests never talk to aria2.
use Pullr\LaravelAria2\Facades\Aria2; Aria2::fake([ 'addUri' => '0000000000000001', 'tellStatus' => [ ['status' => 'active', 'completedLength' => '50', 'totalLength' => '100', 'downloadSpeed' => '1024'], ['status' => 'complete', 'completedLength' => '100', 'totalLength' => '100', 'downloadSpeed' => '0'], ],]); Aria2::client()->addUri(['https://example.com/a.bin']); Aria2::assertAdded('https://example.com/a.bin');
Stubs
| Key | Shape |
| --- | --- |
| addUri | GID string returned by every addUri call. |
| tellStatus | A single status array, or a list of status arrays consumed in order. |
When tellStatus is a list, each call returns the next item. After the list is exhausted the last status is reused.
You may also pass a FakeClient instance:
use Pullr\LaravelAria2\Testing\FakeClient; Aria2::fake(FakeClient::withStubs([ 'addUri' => 'gid-1',]));
Assertions
Aria2::assertAdded('https://example.com/a.bin');
Inspect every recorded RPC call:
$calls = Aria2::fake()->recorded();
Each entry is ['method' => 'aria2.addUri', 'params' => [...]].
Aria2::fake() also rebinds Client, RpcClient, and forgets cached Downloader / metadata resolver instances so subsequent url()->download() calls use the fake.