Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 16 additions & 33 deletions src/agent/tests/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -53,8 +52,7 @@
#[Small]
final class AgentTest extends TestCase
{
#[Test]
public function constructorInitializesWithDefaults(): void
public function testConstructorInitializesWithDefaults(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -64,8 +62,7 @@ public function constructorInitializesWithDefaults(): void
$this->assertInstanceOf(AgentInterface::class, $agent);
}

#[Test]
public function constructorInitializesWithProcessors(): void
public function testConstructorInitializesWithProcessors(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -77,8 +74,7 @@ public function constructorInitializesWithProcessors(): void
$this->assertInstanceOf(AgentInterface::class, $agent);
}

#[Test]
public function constructorSetsAgentOnAgentAwareProcessors(): void
public function testConstructorSetsAgentOnAgentAwareProcessors(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -101,8 +97,7 @@ public function setAgent(AgentInterface $agent): void
$this->assertSame($agent, $agentAwareProcessor->agent);
}

#[Test]
public function constructorThrowsExceptionForInvalidInputProcessor(): void
public function testConstructorThrowsExceptionForInvalidInputProcessor(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -115,8 +110,7 @@ public function constructorThrowsExceptionForInvalidInputProcessor(): void
new Agent($platform, $model, [$invalidProcessor]);
}

#[Test]
public function constructorThrowsExceptionForInvalidOutputProcessor(): void
public function testConstructorThrowsExceptionForInvalidOutputProcessor(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -129,8 +123,7 @@ public function constructorThrowsExceptionForInvalidOutputProcessor(): void
new Agent($platform, $model, [], [$invalidProcessor]);
}

#[Test]
public function callProcessesInputThroughProcessors(): void
public function testCallProcessesInputThroughProcessors(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -156,8 +149,7 @@ public function callProcessesInputThroughProcessors(): void
$this->assertSame($result, $actualResult);
}

#[Test]
public function callProcessesOutputThroughProcessors(): void
public function testCallProcessesOutputThroughProcessors(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -183,8 +175,7 @@ public function callProcessesOutputThroughProcessors(): void
$this->assertSame($result, $actualResult);
}

#[Test]
public function callThrowsExceptionForAudioInputWithoutSupport(): void
public function testCallThrowsExceptionForAudioInputWithoutSupport(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -201,8 +192,7 @@ public function callThrowsExceptionForAudioInputWithoutSupport(): void
$agent->call($messages);
}

#[Test]
public function callThrowsExceptionForImageInputWithoutSupport(): void
public function testCallThrowsExceptionForImageInputWithoutSupport(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -219,8 +209,7 @@ public function callThrowsExceptionForImageInputWithoutSupport(): void
$agent->call($messages);
}

#[Test]
public function callAllowsAudioInputWithSupport(): void
public function testCallAllowsAudioInputWithSupport(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -245,8 +234,7 @@ public function callAllowsAudioInputWithSupport(): void
$this->assertSame($result, $actualResult);
}

#[Test]
public function callAllowsImageInputWithSupport(): void
public function testCallAllowsImageInputWithSupport(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -270,8 +258,7 @@ public function callAllowsImageInputWithSupport(): void
$this->assertSame($result, $actualResult);
}

#[Test]
public function callHandlesClientException(): void
public function testCallHandlesClientException(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand Down Expand Up @@ -314,8 +301,7 @@ public function getResponse(): HttpResponseInterface
$agent->call($messages);
}

#[Test]
public function callHandlesClientExceptionWithEmptyMessage(): void
public function testCallHandlesClientExceptionWithEmptyMessage(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand Down Expand Up @@ -353,8 +339,7 @@ public function getResponse(): HttpResponseInterface
$agent->call($messages);
}

#[Test]
public function callHandlesHttpException(): void
public function testCallHandlesHttpException(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -373,8 +358,7 @@ public function callHandlesHttpException(): void
$agent->call($messages);
}

#[Test]
public function callPassesOptionsToInvoke(): void
public function testCallPassesOptionsToInvoke(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand All @@ -396,8 +380,7 @@ public function callPassesOptionsToInvoke(): void
$this->assertSame($result, $actualResult);
}

#[Test]
public function constructorAcceptsTraversableProcessors(): void
public function testConstructorAcceptsTraversableProcessors(): void
{
$platform = $this->createMock(PlatformInterface::class);
$model = $this->createMock(Model::class);
Expand Down
13 changes: 4 additions & 9 deletions src/agent/tests/ChatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\AI\Agent\AgentInterface;
Expand Down Expand Up @@ -43,8 +42,7 @@ protected function setUp(): void
$this->chat = new Chat($this->agent, $this->store);
}

#[Test]
public function itInitiatesChatByClearingAndSavingMessages(): void
public function testItInitiatesChatByClearingAndSavingMessages(): void
{
$messages = $this->createMock(MessageBagInterface::class);

Expand All @@ -58,8 +56,7 @@ public function itInitiatesChatByClearingAndSavingMessages(): void
$this->chat->initiate($messages);
}

#[Test]
public function itSubmitsUserMessageAndReturnsAssistantMessage(): void
public function testItSubmitsUserMessageAndReturnsAssistantMessage(): void
{
$userMessage = Message::ofUser('Hello, how are you?');
$existingMessages = new MessageBag();
Expand Down Expand Up @@ -98,8 +95,7 @@ public function itSubmitsUserMessageAndReturnsAssistantMessage(): void
$this->assertSame($assistantContent, $result->content);
}

#[Test]
public function itAppendsMessagesToExistingConversation(): void
public function testItAppendsMessagesToExistingConversation(): void
{
$existingUserMessage = Message::ofUser('What is the weather?');
$existingAssistantMessage = Message::ofAssistant('I cannot provide weather information.');
Expand Down Expand Up @@ -140,8 +136,7 @@ public function itAppendsMessagesToExistingConversation(): void
$this->assertSame($newAssistantContent, $result->content);
}

#[Test]
public function itHandlesEmptyMessageStore(): void
public function testItHandlesEmptyMessageStore(): void
{
$userMessage = Message::ofUser('First message');
$emptyMessages = new MessageBag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\AI\Agent\Exception\InvalidArgumentException;
Expand All @@ -33,8 +32,7 @@
#[Small]
final class ModelOverrideInputProcessorTest extends TestCase
{
#[Test]
public function processInputWithValidModelOption(): void
public function testProcessInputWithValidModelOption(): void
{
$gpt = new GPT();
$claude = new Claude();
Expand All @@ -46,8 +44,7 @@ public function processInputWithValidModelOption(): void
$this->assertSame($claude, $input->model);
}

#[Test]
public function processInputWithoutModelOption(): void
public function testProcessInputWithoutModelOption(): void
{
$gpt = new GPT();
$input = new Input($gpt, new MessageBag(), []);
Expand All @@ -58,8 +55,7 @@ public function processInputWithoutModelOption(): void
$this->assertSame($gpt, $input->model);
}

#[Test]
public function processInputWithInvalidModelOption(): void
public function testProcessInputWithInvalidModelOption(): void
{
self::expectException(InvalidArgumentException::class);
self::expectExceptionMessage('Option "model" must be an instance of Symfony\AI\Platform\Model.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\AI\Agent\Input;
Expand Down Expand Up @@ -44,8 +43,7 @@
#[Small]
final class SystemPromptInputProcessorTest extends TestCase
{
#[Test]
public function processInputAddsSystemMessageWhenNoneExists(): void
public function testProcessInputAddsSystemMessageWhenNoneExists(): void
{
$processor = new SystemPromptInputProcessor('This is a system prompt');

Expand All @@ -59,8 +57,7 @@ public function processInputAddsSystemMessageWhenNoneExists(): void
$this->assertSame('This is a system prompt', $messages[0]->content);
}

#[Test]
public function processInputDoesNotAddSystemMessageWhenOneExists(): void
public function testProcessInputDoesNotAddSystemMessageWhenOneExists(): void
{
$processor = new SystemPromptInputProcessor('This is a system prompt');

Expand All @@ -78,8 +75,7 @@ public function processInputDoesNotAddSystemMessageWhenOneExists(): void
$this->assertSame('This is already a system prompt', $messages[0]->content);
}

#[Test]
public function doesNotIncludeToolsIfToolboxIsEmpty(): void
public function testDoesNotIncludeToolsIfToolboxIsEmpty(): void
{
$processor = new SystemPromptInputProcessor(
'This is a system prompt',
Expand All @@ -106,8 +102,7 @@ public function execute(ToolCall $toolCall): mixed
$this->assertSame('This is a system prompt', $messages[0]->content);
}

#[Test]
public function includeToolDefinitions(): void
public function testIncludeToolDefinitions(): void
{
$processor = new SystemPromptInputProcessor(
'This is a system prompt',
Expand Down Expand Up @@ -156,8 +151,7 @@ public function execute(ToolCall $toolCall): mixed
PROMPT, $messages[0]->content);
}

#[Test]
public function withStringableSystemPrompt(): void
public function testWithStringableSystemPrompt(): void
{
$processor = new SystemPromptInputProcessor(
new SystemPromptService(),
Expand Down
16 changes: 5 additions & 11 deletions src/agent/tests/Memory/EmbeddingProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\AI\Agent\Input;
Expand Down Expand Up @@ -42,8 +41,7 @@
#[Small]
final class EmbeddingProviderTest extends TestCase
{
#[Test]
public function itIsDoingNothingWithEmptyMessageBag(): void
public function testItIsDoingNothingWithEmptyMessageBag(): void
{
$platform = $this->createMock(PlatformInterface::class);
$platform->expects($this->never())->method('invoke');
Expand All @@ -64,8 +62,7 @@ public function itIsDoingNothingWithEmptyMessageBag(): void
));
}

#[Test]
public function itIsDoingNothingWithoutUserMessageInBag(): void
public function testItIsDoingNothingWithoutUserMessageInBag(): void
{
$platform = $this->createMock(PlatformInterface::class);
$platform->expects($this->never())->method('invoke');
Expand All @@ -86,8 +83,7 @@ public function itIsDoingNothingWithoutUserMessageInBag(): void
));
}

#[Test]
public function itIsDoingNothingWhenUserMessageHasNoTextContent(): void
public function testItIsDoingNothingWhenUserMessageHasNoTextContent(): void
{
$platform = $this->createMock(PlatformInterface::class);
$platform->expects($this->never())->method('invoke');
Expand All @@ -108,8 +104,7 @@ public function itIsDoingNothingWhenUserMessageHasNoTextContent(): void
));
}

#[Test]
public function itIsNotCreatingMemoryWhenNoVectorsFound(): void
public function testItIsNotCreatingMemoryWhenNoVectorsFound(): void
{
$vectorResult = new VectorResult($vector = new Vector([0.1, 0.2], 2));
$resultPromise = new ResultPromise(
Expand Down Expand Up @@ -143,8 +138,7 @@ public function itIsNotCreatingMemoryWhenNoVectorsFound(): void
$this->assertCount(0, $memory);
}

#[Test]
public function itIsCreatingMemoryWithFoundVectors(): void
public function testItIsCreatingMemoryWithFoundVectors(): void
{
$vectorResult = new VectorResult($vector = new Vector([0.1, 0.2], 2));
$resultPromise = new ResultPromise(
Expand Down
Loading