Add unit and feature tests for ticket processing and article management
- Implement Fake repositories and services for testing purposes. - Create tests for Article API including creation, validation, and listing. - Develop ProcessTicketJobFlowTest to validate ticket processing logic. - Add QuickReplyAdminTest for creating and updating quick replies. - Implement TicketAndArticleModelTest to ensure proper cascading deletes and credential encryption. - Create TicketIngestionTest for ticket creation and job dispatching. - Add TicketShowPageTest to verify rendering of quick replies and tool calls. - Implement unit tests for ClassifierPromptBuilder, EmbeddingService, LlmJsonDecoder, QuickReplyResolver, SupportReplyService, TicketResultPayloadBuilder, TicketToolCallService, and ToolCallRequestValidator.
This commit is contained in:
32
tests/Fakes/FakeLlmClient.php
Normal file
32
tests/Fakes/FakeLlmClient.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Services\Llm\LlmClientInterface;
|
||||
|
||||
class FakeLlmClient implements LlmClientInterface
|
||||
{
|
||||
/** @var array<string, array<int, float>> */
|
||||
public array $embeddings = [];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $responses = [];
|
||||
|
||||
/** @var array<int, array{prompt:string, options:array}> */
|
||||
public array $generatedPrompts = [];
|
||||
|
||||
public function embed(string $text): array
|
||||
{
|
||||
return $this->embeddings[$text] ?? [0.1, 0.2, 0.3];
|
||||
}
|
||||
|
||||
public function generate(string $prompt, array $options = []): string
|
||||
{
|
||||
$this->generatedPrompts[] = [
|
||||
'prompt' => $prompt,
|
||||
'options' => $options,
|
||||
];
|
||||
|
||||
return array_shift($this->responses) ?? '{}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user