Skip to content

Commit 8ac8528

Browse files
committed
minor #472 [Agent] Use ::class constants in test assertions (OskarStark)
This PR was merged into the main branch. Discussion ---------- [Agent] Use `::class` constants in test assertions | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT Replace hardcoded class name strings with ::class constants in exception message assertions for better maintainability and refactoring safety. Commits ------- cc942ee Use ::class constants in test assertions
2 parents 4fae664 + cc942ee commit 8ac8528

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/agent/tests/AgentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testConstructorThrowsExceptionForInvalidInputProcessor()
104104
$invalidProcessor = new \stdClass();
105105

106106
$this->expectException(InvalidArgumentException::class);
107-
$this->expectExceptionMessage('Processor "stdClass" must implement "Symfony\AI\Agent\InputProcessorInterface".');
107+
$this->expectExceptionMessage('Processor "stdClass" must implement "'.InputProcessorInterface::class.'".');
108108

109109
/* @phpstan-ignore-next-line */
110110
new Agent($platform, $model, [$invalidProcessor]);
@@ -117,7 +117,7 @@ public function testConstructorThrowsExceptionForInvalidOutputProcessor()
117117
$invalidProcessor = new \stdClass();
118118

119119
$this->expectException(InvalidArgumentException::class);
120-
$this->expectExceptionMessage('Processor "stdClass" must implement "Symfony\AI\Agent\OutputProcessorInterface".');
120+
$this->expectExceptionMessage('Processor "stdClass" must implement "'.OutputProcessorInterface::class.'".');
121121

122122
/* @phpstan-ignore-next-line */
123123
new Agent($platform, $model, [], [$invalidProcessor]);

src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\AI\Platform\Bridge\OpenAi\Embeddings;
2323
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
2424
use Symfony\AI\Platform\Message\MessageBag;
25+
use Symfony\AI\Platform\Model;
2526

2627
#[CoversClass(ModelOverrideInputProcessor::class)]
2728
#[UsesClass(Gpt::class)]
@@ -58,7 +59,7 @@ public function testProcessInputWithoutModelOption()
5859
public function testProcessInputWithInvalidModelOption()
5960
{
6061
$this->expectException(InvalidArgumentException::class);
61-
$this->expectExceptionMessage('Option "model" must be an instance of "Symfony\AI\Platform\Model".');
62+
$this->expectExceptionMessage('Option "model" must be an instance of "'.Model::class.'".');
6263

6364
$gpt = new Gpt();
6465
$model = new MessageBag();

src/agent/tests/Toolbox/ToolboxTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function testExecuteWithUnknownTool()
162162
public function testExecuteWithMisconfiguredTool()
163163
{
164164
$this->expectException(ToolConfigurationException::class);
165-
$this->expectExceptionMessage('Method "foo" not found in tool "Symfony\AI\Fixtures\Tool\ToolMisconfigured".');
165+
$this->expectExceptionMessage('Method "foo" not found in tool "'.ToolMisconfigured::class.'".');
166166

167167
$toolbox = new Toolbox([new ToolMisconfigured()], new ReflectionToolFactory());
168168

0 commit comments

Comments
 (0)