Skip to content

Commit 2b6f483

Browse files
committed
minor #214 Replace #[Test] attribute by test prefix (chr-hertel)
This PR was merged into the main branch. Discussion ---------- Replace #[Test] attribute by test prefix | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Replacing #196 | Component | `main` | `test-prefix` | | | ---------- | ------ | -------------- | - | | Agent |105 tests, 287 assertions | 105 tests, 287 assertions | ✔️ | | AI Bundle | 14 tests, 34 assertions | 14 tests, 34 assertions | ✔️ | | MCP Bundle | no tests | still no tests | 😞 | | MCP SDK | 23 tests, 57 assertions | 23 tests, 57 assertions | ✔️ | | Platform | 381 tests, 801 assertions | 381 tests, 801 assertions | ✔️ | | Store | 90 tests, 411 assertions | 90 tests, 411 assertions | ✔️ | Commits ------- 2f7320d Replace #[Test] attribute by test prefix
2 parents 0f7d5eb + 2f7320d commit 2b6f483

File tree

123 files changed

+527
-1178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+527
-1178
lines changed

src/agent/tests/AgentTest.php

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Small;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\Attributes\UsesClass;
1817
use PHPUnit\Framework\TestCase;
1918
use Psr\Log\LoggerInterface;
@@ -53,8 +52,7 @@
5352
#[Small]
5453
final class AgentTest extends TestCase
5554
{
56-
#[Test]
57-
public function constructorInitializesWithDefaults(): void
55+
public function testConstructorInitializesWithDefaults(): void
5856
{
5957
$platform = $this->createMock(PlatformInterface::class);
6058
$model = $this->createMock(Model::class);
@@ -64,8 +62,7 @@ public function constructorInitializesWithDefaults(): void
6462
$this->assertInstanceOf(AgentInterface::class, $agent);
6563
}
6664

67-
#[Test]
68-
public function constructorInitializesWithProcessors(): void
65+
public function testConstructorInitializesWithProcessors(): void
6966
{
7067
$platform = $this->createMock(PlatformInterface::class);
7168
$model = $this->createMock(Model::class);
@@ -77,8 +74,7 @@ public function constructorInitializesWithProcessors(): void
7774
$this->assertInstanceOf(AgentInterface::class, $agent);
7875
}
7976

80-
#[Test]
81-
public function constructorSetsAgentOnAgentAwareProcessors(): void
77+
public function testConstructorSetsAgentOnAgentAwareProcessors(): void
8278
{
8379
$platform = $this->createMock(PlatformInterface::class);
8480
$model = $this->createMock(Model::class);
@@ -101,8 +97,7 @@ public function setAgent(AgentInterface $agent): void
10197
$this->assertSame($agent, $agentAwareProcessor->agent);
10298
}
10399

104-
#[Test]
105-
public function constructorThrowsExceptionForInvalidInputProcessor(): void
100+
public function testConstructorThrowsExceptionForInvalidInputProcessor(): void
106101
{
107102
$platform = $this->createMock(PlatformInterface::class);
108103
$model = $this->createMock(Model::class);
@@ -115,8 +110,7 @@ public function constructorThrowsExceptionForInvalidInputProcessor(): void
115110
new Agent($platform, $model, [$invalidProcessor]);
116111
}
117112

118-
#[Test]
119-
public function constructorThrowsExceptionForInvalidOutputProcessor(): void
113+
public function testConstructorThrowsExceptionForInvalidOutputProcessor(): void
120114
{
121115
$platform = $this->createMock(PlatformInterface::class);
122116
$model = $this->createMock(Model::class);
@@ -129,8 +123,7 @@ public function constructorThrowsExceptionForInvalidOutputProcessor(): void
129123
new Agent($platform, $model, [], [$invalidProcessor]);
130124
}
131125

132-
#[Test]
133-
public function callProcessesInputThroughProcessors(): void
126+
public function testCallProcessesInputThroughProcessors(): void
134127
{
135128
$platform = $this->createMock(PlatformInterface::class);
136129
$model = $this->createMock(Model::class);
@@ -156,8 +149,7 @@ public function callProcessesInputThroughProcessors(): void
156149
$this->assertSame($result, $actualResult);
157150
}
158151

159-
#[Test]
160-
public function callProcessesOutputThroughProcessors(): void
152+
public function testCallProcessesOutputThroughProcessors(): void
161153
{
162154
$platform = $this->createMock(PlatformInterface::class);
163155
$model = $this->createMock(Model::class);
@@ -183,8 +175,7 @@ public function callProcessesOutputThroughProcessors(): void
183175
$this->assertSame($result, $actualResult);
184176
}
185177

186-
#[Test]
187-
public function callThrowsExceptionForAudioInputWithoutSupport(): void
178+
public function testCallThrowsExceptionForAudioInputWithoutSupport(): void
188179
{
189180
$platform = $this->createMock(PlatformInterface::class);
190181
$model = $this->createMock(Model::class);
@@ -201,8 +192,7 @@ public function callThrowsExceptionForAudioInputWithoutSupport(): void
201192
$agent->call($messages);
202193
}
203194

204-
#[Test]
205-
public function callThrowsExceptionForImageInputWithoutSupport(): void
195+
public function testCallThrowsExceptionForImageInputWithoutSupport(): void
206196
{
207197
$platform = $this->createMock(PlatformInterface::class);
208198
$model = $this->createMock(Model::class);
@@ -219,8 +209,7 @@ public function callThrowsExceptionForImageInputWithoutSupport(): void
219209
$agent->call($messages);
220210
}
221211

222-
#[Test]
223-
public function callAllowsAudioInputWithSupport(): void
212+
public function testCallAllowsAudioInputWithSupport(): void
224213
{
225214
$platform = $this->createMock(PlatformInterface::class);
226215
$model = $this->createMock(Model::class);
@@ -245,8 +234,7 @@ public function callAllowsAudioInputWithSupport(): void
245234
$this->assertSame($result, $actualResult);
246235
}
247236

248-
#[Test]
249-
public function callAllowsImageInputWithSupport(): void
237+
public function testCallAllowsImageInputWithSupport(): void
250238
{
251239
$platform = $this->createMock(PlatformInterface::class);
252240
$model = $this->createMock(Model::class);
@@ -270,8 +258,7 @@ public function callAllowsImageInputWithSupport(): void
270258
$this->assertSame($result, $actualResult);
271259
}
272260

273-
#[Test]
274-
public function callHandlesClientException(): void
261+
public function testCallHandlesClientException(): void
275262
{
276263
$platform = $this->createMock(PlatformInterface::class);
277264
$model = $this->createMock(Model::class);
@@ -314,8 +301,7 @@ public function getResponse(): HttpResponseInterface
314301
$agent->call($messages);
315302
}
316303

317-
#[Test]
318-
public function callHandlesClientExceptionWithEmptyMessage(): void
304+
public function testCallHandlesClientExceptionWithEmptyMessage(): void
319305
{
320306
$platform = $this->createMock(PlatformInterface::class);
321307
$model = $this->createMock(Model::class);
@@ -353,8 +339,7 @@ public function getResponse(): HttpResponseInterface
353339
$agent->call($messages);
354340
}
355341

356-
#[Test]
357-
public function callHandlesHttpException(): void
342+
public function testCallHandlesHttpException(): void
358343
{
359344
$platform = $this->createMock(PlatformInterface::class);
360345
$model = $this->createMock(Model::class);
@@ -373,8 +358,7 @@ public function callHandlesHttpException(): void
373358
$agent->call($messages);
374359
}
375360

376-
#[Test]
377-
public function callPassesOptionsToInvoke(): void
361+
public function testCallPassesOptionsToInvoke(): void
378362
{
379363
$platform = $this->createMock(PlatformInterface::class);
380364
$model = $this->createMock(Model::class);
@@ -396,8 +380,7 @@ public function callPassesOptionsToInvoke(): void
396380
$this->assertSame($result, $actualResult);
397381
}
398382

399-
#[Test]
400-
public function constructorAcceptsTraversableProcessors(): void
383+
public function testConstructorAcceptsTraversableProcessors(): void
401384
{
402385
$platform = $this->createMock(PlatformInterface::class);
403386
$model = $this->createMock(Model::class);

src/agent/tests/ChatTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Small;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\Attributes\UsesClass;
1817
use PHPUnit\Framework\TestCase;
1918
use Symfony\AI\Agent\AgentInterface;
@@ -43,8 +42,7 @@ protected function setUp(): void
4342
$this->chat = new Chat($this->agent, $this->store);
4443
}
4544

46-
#[Test]
47-
public function itInitiatesChatByClearingAndSavingMessages(): void
45+
public function testItInitiatesChatByClearingAndSavingMessages(): void
4846
{
4947
$messages = $this->createMock(MessageBagInterface::class);
5048

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

61-
#[Test]
62-
public function itSubmitsUserMessageAndReturnsAssistantMessage(): void
59+
public function testItSubmitsUserMessageAndReturnsAssistantMessage(): void
6360
{
6461
$userMessage = Message::ofUser('Hello, how are you?');
6562
$existingMessages = new MessageBag();
@@ -98,8 +95,7 @@ public function itSubmitsUserMessageAndReturnsAssistantMessage(): void
9895
$this->assertSame($assistantContent, $result->content);
9996
}
10097

101-
#[Test]
102-
public function itAppendsMessagesToExistingConversation(): void
98+
public function testItAppendsMessagesToExistingConversation(): void
10399
{
104100
$existingUserMessage = Message::ofUser('What is the weather?');
105101
$existingAssistantMessage = Message::ofAssistant('I cannot provide weather information.');
@@ -140,8 +136,7 @@ public function itAppendsMessagesToExistingConversation(): void
140136
$this->assertSame($newAssistantContent, $result->content);
141137
}
142138

143-
#[Test]
144-
public function itHandlesEmptyMessageStore(): void
139+
public function testItHandlesEmptyMessageStore(): void
145140
{
146141
$userMessage = Message::ofUser('First message');
147142
$emptyMessages = new MessageBag();

src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Small;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\Attributes\UsesClass;
1817
use PHPUnit\Framework\TestCase;
1918
use Symfony\AI\Agent\Exception\InvalidArgumentException;
@@ -33,8 +32,7 @@
3332
#[Small]
3433
final class ModelOverrideInputProcessorTest extends TestCase
3534
{
36-
#[Test]
37-
public function processInputWithValidModelOption(): void
35+
public function testProcessInputWithValidModelOption(): void
3836
{
3937
$gpt = new GPT();
4038
$claude = new Claude();
@@ -46,8 +44,7 @@ public function processInputWithValidModelOption(): void
4644
$this->assertSame($claude, $input->model);
4745
}
4846

49-
#[Test]
50-
public function processInputWithoutModelOption(): void
47+
public function testProcessInputWithoutModelOption(): void
5148
{
5249
$gpt = new GPT();
5350
$input = new Input($gpt, new MessageBag(), []);
@@ -58,8 +55,7 @@ public function processInputWithoutModelOption(): void
5855
$this->assertSame($gpt, $input->model);
5956
}
6057

61-
#[Test]
62-
public function processInputWithInvalidModelOption(): void
58+
public function testProcessInputWithInvalidModelOption(): void
6359
{
6460
self::expectException(InvalidArgumentException::class);
6561
self::expectExceptionMessage('Option "model" must be an instance of Symfony\AI\Platform\Model.');

src/agent/tests/InputProcessor/SystemPromptInputProcessorTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Small;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\Attributes\UsesClass;
1817
use PHPUnit\Framework\TestCase;
1918
use Symfony\AI\Agent\Input;
@@ -44,8 +43,7 @@
4443
#[Small]
4544
final class SystemPromptInputProcessorTest extends TestCase
4645
{
47-
#[Test]
48-
public function processInputAddsSystemMessageWhenNoneExists(): void
46+
public function testProcessInputAddsSystemMessageWhenNoneExists(): void
4947
{
5048
$processor = new SystemPromptInputProcessor('This is a system prompt');
5149

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

62-
#[Test]
63-
public function processInputDoesNotAddSystemMessageWhenOneExists(): void
60+
public function testProcessInputDoesNotAddSystemMessageWhenOneExists(): void
6461
{
6562
$processor = new SystemPromptInputProcessor('This is a system prompt');
6663

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

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

109-
#[Test]
110-
public function includeToolDefinitions(): void
105+
public function testIncludeToolDefinitions(): void
111106
{
112107
$processor = new SystemPromptInputProcessor(
113108
'This is a system prompt',
@@ -156,8 +151,7 @@ public function execute(ToolCall $toolCall): mixed
156151
PROMPT, $messages[0]->content);
157152
}
158153

159-
#[Test]
160-
public function withStringableSystemPrompt(): void
154+
public function testWithStringableSystemPrompt(): void
161155
{
162156
$processor = new SystemPromptInputProcessor(
163157
new SystemPromptService(),

src/agent/tests/Memory/EmbeddingProviderTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
1515
use PHPUnit\Framework\Attributes\Small;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\Attributes\UsesClass;
1817
use PHPUnit\Framework\TestCase;
1918
use Symfony\AI\Agent\Input;
@@ -42,8 +41,7 @@
4241
#[Small]
4342
final class EmbeddingProviderTest extends TestCase
4443
{
45-
#[Test]
46-
public function itIsDoingNothingWithEmptyMessageBag(): void
44+
public function testItIsDoingNothingWithEmptyMessageBag(): void
4745
{
4846
$platform = $this->createMock(PlatformInterface::class);
4947
$platform->expects($this->never())->method('invoke');
@@ -64,8 +62,7 @@ public function itIsDoingNothingWithEmptyMessageBag(): void
6462
));
6563
}
6664

67-
#[Test]
68-
public function itIsDoingNothingWithoutUserMessageInBag(): void
65+
public function testItIsDoingNothingWithoutUserMessageInBag(): void
6966
{
7067
$platform = $this->createMock(PlatformInterface::class);
7168
$platform->expects($this->never())->method('invoke');
@@ -86,8 +83,7 @@ public function itIsDoingNothingWithoutUserMessageInBag(): void
8683
));
8784
}
8885

89-
#[Test]
90-
public function itIsDoingNothingWhenUserMessageHasNoTextContent(): void
86+
public function testItIsDoingNothingWhenUserMessageHasNoTextContent(): void
9187
{
9288
$platform = $this->createMock(PlatformInterface::class);
9389
$platform->expects($this->never())->method('invoke');
@@ -108,8 +104,7 @@ public function itIsDoingNothingWhenUserMessageHasNoTextContent(): void
108104
));
109105
}
110106

111-
#[Test]
112-
public function itIsNotCreatingMemoryWhenNoVectorsFound(): void
107+
public function testItIsNotCreatingMemoryWhenNoVectorsFound(): void
113108
{
114109
$vectorResult = new VectorResult($vector = new Vector([0.1, 0.2], 2));
115110
$resultPromise = new ResultPromise(
@@ -143,8 +138,7 @@ public function itIsNotCreatingMemoryWhenNoVectorsFound(): void
143138
$this->assertCount(0, $memory);
144139
}
145140

146-
#[Test]
147-
public function itIsCreatingMemoryWithFoundVectors(): void
141+
public function testItIsCreatingMemoryWithFoundVectors(): void
148142
{
149143
$vectorResult = new VectorResult($vector = new Vector([0.1, 0.2], 2));
150144
$resultPromise = new ResultPromise(

0 commit comments

Comments
 (0)