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:
40
tests/Unit/LlmJsonDecoderTest.php
Normal file
40
tests/Unit/LlmJsonDecoderTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\LlmJsonDecoder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LlmJsonDecoderTest extends TestCase
|
||||
{
|
||||
public function test_it_decodes_plain_json(): void
|
||||
{
|
||||
$decoder = new LlmJsonDecoder;
|
||||
$decoded = $decoder->decode('{"a":1}');
|
||||
|
||||
$this->assertSame(['a' => 1], $decoded);
|
||||
}
|
||||
|
||||
public function test_it_decodes_fenced_json(): void
|
||||
{
|
||||
$decoder = new LlmJsonDecoder;
|
||||
$decoded = $decoder->decode("```json\n{\"a\":2}\n```");
|
||||
|
||||
$this->assertSame(['a' => 2], $decoded);
|
||||
}
|
||||
|
||||
public function test_it_extracts_json_from_mixed_text(): void
|
||||
{
|
||||
$decoder = new LlmJsonDecoder;
|
||||
$decoded = $decoder->decode("noise before {\"a\":3} noise after");
|
||||
|
||||
$this->assertSame(['a' => 3], $decoded);
|
||||
}
|
||||
|
||||
public function test_it_returns_null_on_invalid_json(): void
|
||||
{
|
||||
$decoder = new LlmJsonDecoder;
|
||||
|
||||
$this->assertNull($decoder->decode('no json here'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user