|
15 | 15 | use PHPUnit\Framework\TestCase;
|
16 | 16 | use Symfony\AI\Agent\MockAgent;
|
17 | 17 | use Symfony\AI\Platform\Message\AssistantMessage;
|
| 18 | +use Symfony\AI\Platform\Message\Content\Text; |
18 | 19 | use Symfony\AI\Platform\Message\MessageBag;
|
19 | 20 | use Symfony\AI\Platform\Message\SystemMessage;
|
20 | 21 | use Symfony\AI\Platform\Message\UserMessage;
|
@@ -65,6 +66,7 @@ public function testSubmitMessageAddsUserMessageAndAgentResponse()
|
65 | 66 | // Check user message
|
66 | 67 | $userMessage = $messageList[1];
|
67 | 68 | $this->assertInstanceOf(UserMessage::class, $userMessage);
|
| 69 | + $this->assertInstanceOf(Text::class, $userMessage->getContent()[0]); |
68 | 70 | $this->assertSame('What is Symfony?', $userMessage->getContent()[0]->getText());
|
69 | 71 |
|
70 | 72 | // Check assistant message
|
@@ -169,9 +171,16 @@ public function testAgentReceivesFullConversationHistory()
|
169 | 171 | $this->assertCount(5, $messages);
|
170 | 172 |
|
171 | 173 | // Verify the conversation flow (with 5 messages)
|
172 |
| - $this->assertStringContainsString('helpful assistant', $messages[0]->getContent()); // system |
| 174 | + $this->assertInstanceOf(SystemMessage::class, $messages[0]); |
| 175 | + $this->assertStringContainsString('helpful assistant', $messages[0]->getContent()); |
| 176 | + $this->assertInstanceOf(UserMessage::class, $messages[1]); |
| 177 | + $this->assertCount(1, $messages[1]->getContent()); |
| 178 | + $this->assertInstanceOf(Text::class, $messages[1]->getContent()[0]); |
173 | 179 | $this->assertSame('What is Symfony?', $messages[1]->getContent()[0]->getText()); // user1
|
174 | 180 | $this->assertSame('Symfony is a PHP web framework for building web applications and APIs.', $messages[2]->getContent()); // assistant1
|
| 181 | + $this->assertInstanceOf(UserMessage::class, $messages[3]); |
| 182 | + $this->assertCount(1, $messages[3]->getContent()); |
| 183 | + $this->assertInstanceOf(Text::class, $messages[3]->getContent()[0]); |
175 | 184 | $this->assertSame('Tell me more', $messages[3]->getContent()[0]->getText()); // user2
|
176 | 185 | // The 5th message appears to be the previous assistant response or another system message
|
177 | 186 | }
|
|
0 commit comments