|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of TYPO3 CMS-based extension "aim" by b13. |
| 7 | + * |
| 8 | + * It is free software; you can redistribute it and/or modify it under |
| 9 | + * the terms of the GNU General Public License, either version 2 |
| 10 | + * of the License, or any later version. |
| 11 | + */ |
| 12 | + |
| 13 | +namespace B13\Aim\Tests\Unit\Provider\SymfonyAi; |
| 14 | + |
| 15 | +use B13\Aim\Provider\SymfonyAi\SymfonyAiPlatformAdapter; |
| 16 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 17 | +use PHPUnit\Framework\Attributes\Test; |
| 18 | +use PHPUnit\Framework\TestCase; |
| 19 | + |
| 20 | +final class SymfonyAiPlatformAdapterTest extends TestCase |
| 21 | +{ |
| 22 | + public static function maxTokensKeyProvider(): \Generator |
| 23 | + { |
| 24 | + yield 'OpenAI Responses API' => [ |
| 25 | + 'Symfony\\AI\\Platform\\Bridge\\OpenAi\\PlatformFactory', |
| 26 | + 'max_output_tokens', |
| 27 | + ]; |
| 28 | + yield 'OpenResponses bridge' => [ |
| 29 | + 'Symfony\\AI\\Platform\\Bridge\\OpenResponses\\PlatformFactory', |
| 30 | + 'max_output_tokens', |
| 31 | + ]; |
| 32 | + yield 'Anthropic Messages API' => [ |
| 33 | + 'Symfony\\AI\\Platform\\Bridge\\Anthropic\\PlatformFactory', |
| 34 | + 'max_tokens', |
| 35 | + ]; |
| 36 | + yield 'Mistral' => [ |
| 37 | + 'Symfony\\AI\\Platform\\Bridge\\Mistral\\PlatformFactory', |
| 38 | + 'max_tokens', |
| 39 | + ]; |
| 40 | + yield 'Ollama' => [ |
| 41 | + 'Symfony\\AI\\Platform\\Bridge\\Ollama\\PlatformFactory', |
| 42 | + 'max_tokens', |
| 43 | + ]; |
| 44 | + yield 'unknown bridge falls back to max_tokens' => [ |
| 45 | + 'Acme\\AiBridge\\PlatformFactory', |
| 46 | + 'max_tokens', |
| 47 | + ]; |
| 48 | + } |
| 49 | + |
| 50 | + #[Test] |
| 51 | + #[DataProvider('maxTokensKeyProvider')] |
| 52 | + public function resolveMaxTokensKeyMapsBridgeToCorrectOptionName(string $factoryClass, string $expectedKey): void |
| 53 | + { |
| 54 | + self::assertSame($expectedKey, SymfonyAiPlatformAdapter::resolveMaxTokensKey($factoryClass)); |
| 55 | + } |
| 56 | +} |
0 commit comments