trait InteractsWithFakeAgents

Properties

protected array $fakeAgentGateways

All of the registered fake agent gateways.

protected array $recordedPrompts

All of the recorded agent prompts.

protected array $recordedQueuedPrompts

All of the recorded agent prompts that were queued.

Methods

fakeAgent(string $agent, Closure|array $responses = [])

Fake the responses returned by the given agent.

bool
hasFakeGatewayFor(Agent|string $agent)

Determine if the given agent has been faked.

fakeGatewayFor(Agent $agent)

Get a fake gateway instance for the given agent.

recordPrompt(AgentPrompt|QueuedAgentPrompt $prompt)

Record the given prompt for the faked agent.

assertAgentWasPrompted(string $agent, Closure|string $callback, array|null $prompts = null, string|null $message = null)

Assert that a prompt was received matching a given truth test.

assertAgentWasPromptedTimes(string $agent, int $times = 1)

Assert that a certain number of prompts were received.

assertAgentWasQueued(string $agent, Closure|string $callback)

Assert that a prompt was received matching a given truth test.

assertAgentNotPrompted(string $agent, Closure|string $callback, array|null $prompts = null, string|null $message = null)

Assert that a prompt was not received matching a given truth test.

assertAgentNotQueued(string $agent, Closure|string $callback)

Assert that a queued prompt was not received matching a given truth test.

assertAgentNeverPrompted(string $agent)

Assert that no prompts were received.

assertAgentNeverQueued(string $agent)

Assert that no queued prompts were received.

Details

at line 40
FakeTextGateway fakeAgent(string $agent, Closure|array $responses = [])

Fake the responses returned by the given agent.

On the shared manager, the fake gateway affects every request.

Parameters

string $agent
Closure|array $responses

Return Value

FakeTextGateway

at line 52
bool hasFakeGatewayFor(Agent|string $agent)

Determine if the given agent has been faked.

Parameters

Agent|string $agent

Return Value

bool

at line 63
FakeTextGateway fakeGatewayFor(Agent $agent)

Get a fake gateway instance for the given agent.

Parameters

Agent $agent

Return Value

FakeTextGateway

at line 75
InteractsWithFakeAgents recordPrompt(AgentPrompt|QueuedAgentPrompt $prompt)

Record the given prompt for the faked agent.

Recorded prompts remain on the worker-shared manager.

Parameters

AgentPrompt|QueuedAgentPrompt $prompt

Return Value

InteractsWithFakeAgents

at line 90
InteractsWithFakeAgents assertAgentWasPrompted(string $agent, Closure|string $callback, array|null $prompts = null, string|null $message = null)

Assert that a prompt was received matching a given truth test.

Parameters

string $agent
Closure|string $callback
array|null $prompts
string|null $message

Return Value

InteractsWithFakeAgents

at line 111
InteractsWithFakeAgents assertAgentWasPromptedTimes(string $agent, int $times = 1)

Assert that a certain number of prompts were received.

Parameters

string $agent
int $times

Return Value

InteractsWithFakeAgents

at line 131
InteractsWithFakeAgents assertAgentWasQueued(string $agent, Closure|string $callback)

Assert that a prompt was received matching a given truth test.

Parameters

string $agent
Closure|string $callback

Return Value

InteractsWithFakeAgents

at line 144
InteractsWithFakeAgents assertAgentNotPrompted(string $agent, Closure|string $callback, array|null $prompts = null, string|null $message = null)

Assert that a prompt was not received matching a given truth test.

Parameters

string $agent
Closure|string $callback
array|null $prompts
string|null $message

Return Value

InteractsWithFakeAgents

at line 165
InteractsWithFakeAgents assertAgentNotQueued(string $agent, Closure|string $callback)

Assert that a queued prompt was not received matching a given truth test.

Parameters

string $agent
Closure|string $callback

Return Value

InteractsWithFakeAgents

at line 178
InteractsWithFakeAgents assertAgentNeverPrompted(string $agent)

Assert that no prompts were received.

Parameters

string $agent

Return Value

InteractsWithFakeAgents

at line 191
InteractsWithFakeAgents assertAgentNeverQueued(string $agent)

Assert that no queued prompts were received.

Parameters

string $agent

Return Value

InteractsWithFakeAgents