Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstalliTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use Laravel’s AI SDK fakes to test predictable agent behavior, then test the surrounding HTTP, application, queue, and database boundaries separately. Add live-provider checks only for risks a fake cannot answer: real credentials, request compatibility, provider behavior, or output properties that matter to your product. A fake is a controlled input for your application—not evidence that a model is reliable.
The examples and links below refer to Laravel 13.x documentation and its versioned AI SDK docs. Check the framework and SDK versions installed in your project before copying APIs.
What does an agent fake prove?
An agent fake lets a test provide a known response without depending on a live model. That makes it useful for exercising decisions your application owns: assembling prompt context, deciding whether to call an agent, handling its response, branching on returned fields, and formatting a result for a user. It does not run a model or establish that the response is semantically good.
Laravel’s Laravel AI SDK documentation describes fakes that return a default generated response, an explicit response sequence, or a response produced by a closure. A closure is useful when the response should depend on the prompt received.
#1 Best Overall
use IlluminateSupportFacadesAgent;
Agent::fake('A concise answer for the test.');
$response = app(AnswerAgent::class)->respond('How do I reset my password?');
Agent::assertPrompted(fn ($prompt) =>
str_contains($prompt, 'How do I reset my password?')
);
For a multi-step interaction, provide a sequence of responses; for prompt-dependent behavior, use the SDK’s closure-based fake. The SDK also documents prompt assertions, including assertPrompted, assertNotPrompted, and assertNeverPrompted. Use the assertion that matches the behavior under test rather than treating a returned string as the only signal.
Structured output
If an agent declares a structured output schema and the fake has no explicit data, the SDK can generate fake data shaped to that schema. This helps test application-side parsing and branching against expected fields. It does not validate whether a real provider will return valid data or whether the values make sense.
How do I stop real HTTP calls in tests?
When an agent tool or application service uses Laravel’s HTTP client to call an external API, fake the response and assert the outgoing request. Laravel’s HTTP Client documentation covers response fakes, request assertions, and blocking unmatched requests.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsuse IlluminateSupportFacadesHttp;
Http::preventStrayRequests();
Http::fake([
'api.example.test/*' => Http::response(['status' => 'ok'], 200),
]);
$result = app(ExternalLookup::class)->find('item-42');
Http::assertSent(fn ($request) =>
$request->url() === 'https://api.example.test/items/item-42'
&& $request['include_details'] === true
);
The example hostname is illustrative; replace it with the endpoint your application actually uses. preventStrayRequests() makes requests without a matching fake fail instead of reaching a real URL. Laravel also documents allowStrayRequests() for intentionally allowing selected patterns.
These fakes and assertions apply to requests made through Laravel’s HTTP client. They do not automatically intercept every network transport or a provider SDK that bypasses that client. For such integrations, use the applicable SDK’s testing seam or keep the test isolated as a live-provider check.
How should feature tests exercise an agent workflow?
A feature test can send a full HTTP request through Laravel and check the observable application behavior, rather than testing only an agent class. Laravel’s Testing: Getting Started guide says, “Generally, most of your tests should be feature tests.” That is framework guidance, not a measured coverage statistic.
Rank #3
For an endpoint that uses an agent, fake the agent response, call the application route, and assert the status, response structure, and relevant behavior. This tests routing and interactions among Laravel components while keeping model output controlled. Laravel’s HTTP Tests documentation describes the request and response testing facilities.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Queued agent work
Decide whether a test is checking that work is dispatched or whether it is checking the callback’s behavior after generation. The AI SDK docs state that faked queued image, audio, transcription, or embedding generation invokes registered then callbacks with the fake response. Combining that behavior with Laravel’s Queue::fake() can prevent the callback from running when the test’s purpose is queue dispatch. Verify the behavior for the specific generation type and SDK version in use.
Laravel’s Mocking documentation covers replacing dependencies and facades in tests; use the narrowest seam that lets the test focus on its actual claim.
Rank #4
How do I verify persisted effects?
If an agent workflow changes application data, verify the database state instead of trusting a success-sounding response. Laravel’s Database Testing guide documents RefreshDatabase, model factories, seeders, and database assertions.
For example, a feature test can fake the agent’s structured response, submit the request, then assert that the expected record exists with the intended values. Include authorization or ownership checks where those determine which records the user may create or change. A database assertion establishes the persisted effect; it does not establish that generated content is factually or semantically sound.
Recommended Free Tools
When do I need a live-provider test?
Use a live check only when the question requires a real provider. A fake cannot establish that credentials are valid, that a provider accepts the exact request, or that provider-specific features such as streaming or structured output work with the configured model. It also cannot show that real output meets product expectations.
Best Value
Keep live checks separate from fast deterministic application tests. Control their inputs and side effects, and define the team’s own schedule and execution environment. Laravel’s reviewed documentation does not prescribe a universal frequency, budget, or CI placement for these tests.
Avoid requiring nondeterministic prose to equal one exact string. Instead, check properties that matter to the application—for example, whether a response parses, required structured fields are present, or tool use follows the policy your application expects. For subjective quality, use an evaluation set and human review where appropriate; these are implementation choices, not Laravel-prescribed methods.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Which test layer answers which question?
| Layer | What it can establish | What it cannot establish by itself |
|---|---|---|
| Agent fake with an application test | Prompt construction, response handling, branching, and decisions about calling an agent | Real provider compatibility or model quality |
| HTTP fake and request assertion | Outgoing request shape and handling of selected response or error cases | Behavior of transports that bypass Laravel’s HTTP client, or real service availability |
| Laravel feature test | Application routing and interactions across Laravel components | Live-provider correctness when the provider boundary remains faked |
| Database assertion | Persisted state and intended database effects | Whether generated content is semantically good |
| Selective provider integration check | Real credentials, request compatibility, and response handling for the configured setup | Broad model quality across prompts, time, or all provider and model versions |
The practical approach is layered: use deterministic tests for application-owned behavior, feature tests for the Laravel path a user actually takes, database assertions for state changes, and live checks only for provider-specific uncertainty. Pest and PHPUnit are both supported by Laravel; choose the runner already used by your application.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

