Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
MockFactory
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 __construct
n/a
0 / 0
n/a
0 / 0
1
 createMockAiClient
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\IntegrationTests\Applications;
3
4use Apie\AiInstructor\AiClient;
5use Symfony\Component\HttpClient\MockHttpClient;
6use Symfony\Component\HttpClient\Response\MockResponse;
7
8final class MockFactory
9{
10    /**
11     * @codeCoverageIgnore
12     */
13    private function __construct()
14    {
15    }
16
17    public static function createMockAiClient(): AiClient
18    {
19        $responseFactory = function () {
20            return new MockResponse(json_encode([
21                "model" => "test-model",
22                "created_at" => "2025-04-19T14:03:51.5655428Z",
23                "message" => [
24                    "role" => "assistant",
25                    "content" => '"CZ"',
26                ],
27                "done_reason" => "stop",
28                "done" => true,
29                "total_duration" => 2320197200,
30                "load_duration" => 18822000,
31                "prompt_eval_count" => 69,
32                "prompt_eval_duration" => 1945480500,
33                "eval_count" => 5,
34                "eval_duration" => 341499600,
35            ]));
36        };
37        return AiClient::create(
38            new MockHttpClient($responseFactory),
39            'http://llm:5432/test',
40            'secret'
41        );
42    }
43}