Skip to content

Commit 6651405

Browse files
minor #223 Remove void return type from tests (OskarStark)
This PR was merged into the main branch. Discussion ---------- Remove `void` return type from tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT To make Fabbot (and `@nicolas`-grekas) happy 😃 Commits ------- 2f97be9 Remove `void` return type from tests
2 parents cff6f0d + 2f97be9 commit 6651405

File tree

133 files changed

+557
-541
lines changed

Some content is hidden

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

133 files changed

+557
-541
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
->setRiskyAllowed(true)
4444
->setFinder(
4545
(new PhpCsFixer\Finder())
46-
->in([__DIR__.'/demo', __DIR__.'/examples', __DIR__.'/fixtures', __DIR__.'/src'])
46+
->in(__DIR__.'/{demo,examples,fixtures,src}')
4747
->append([__FILE__])
4848
->exclude('var')
4949
)

demo/phpstan.dist.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ parameters:
66
- public/
77
- src/
88
- tests/
9+
ignoreErrors:
10+
-
11+
message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#"

demo/tests/Blog/LoaderTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use App\Blog\FeedLoader;
1515
use App\Blog\Post;
1616
use PHPUnit\Framework\Attributes\CoversClass;
17-
use PHPUnit\Framework\Attributes\Test;
1817
use PHPUnit\Framework\Attributes\UsesClass;
1918
use PHPUnit\Framework\TestCase;
2019
use Symfony\Component\HttpClient\MockHttpClient;
@@ -24,8 +23,7 @@
2423
#[UsesClass(Post::class)]
2524
final class LoaderTest extends TestCase
2625
{
27-
#[Test]
28-
public function load(): void
26+
public function testLoad()
2927
{
3028
$response = MockResponse::fromFile(__DIR__.'/fixtures/blog.rss');
3129
$client = new MockHttpClient($response);

demo/tests/Blog/PostTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313

1414
use App\Blog\Post;
1515
use PHPUnit\Framework\Attributes\CoversClass;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use PHPUnit\Framework\TestCase;
1817
use Symfony\Component\Uid\Uuid;
1918

2019
#[CoversClass(Post::class)]
2120
final class PostTest extends TestCase
2221
{
23-
#[Test]
24-
public function postToString(): void
22+
public function testPostToString()
2523
{
2624
$post = new Post(
2725
Uuid::v4(),
@@ -43,8 +41,7 @@ public function postToString(): void
4341
$this->assertSame($expected, $post->toString());
4442
}
4543

46-
#[Test]
47-
public function postToArray(): void
44+
public function testPostToArray()
4845
{
4946
$id = Uuid::v4();
5047
$post = new Post(

demo/tests/SmokeTest.php

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

1414
use PHPUnit\Framework\Attributes\CoversNothing;
1515
use PHPUnit\Framework\Attributes\DataProvider;
16-
use PHPUnit\Framework\Attributes\Test;
1716
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1817
use Symfony\UX\LiveComponent\Test\InteractsWithLiveComponents;
1918

@@ -22,8 +21,7 @@ final class SmokeTest extends WebTestCase
2221
{
2322
use InteractsWithLiveComponents;
2423

25-
#[Test]
26-
public function index(): void
24+
public function testIndex()
2725
{
2826
$client = static::createClient();
2927
$client->request('GET', '/');
@@ -33,9 +31,8 @@ public function index(): void
3331
self::assertSelectorCount(5, '.card');
3432
}
3533

36-
#[Test]
3734
#[DataProvider('provideChats')]
38-
public function chats(string $path, string $expectedHeadline): void
35+
public function testChats(string $path, string $expectedHeadline)
3936
{
4037
$client = static::createClient();
4138
$client->request('GET', $path);

src/agent/phpstan.dist.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ parameters:
77
- src/
88
- tests/
99
ignoreErrors:
10+
-
11+
message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#"
1012
-
1113
identifier: missingType.iterableValue
1214
path: tests/*

src/agent/tests/AgentTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#[Small]
5353
final class AgentTest extends TestCase
5454
{
55-
public function testConstructorInitializesWithDefaults(): void
55+
public function testConstructorInitializesWithDefaults()
5656
{
5757
$platform = $this->createMock(PlatformInterface::class);
5858
$model = $this->createMock(Model::class);
@@ -62,7 +62,7 @@ public function testConstructorInitializesWithDefaults(): void
6262
$this->assertInstanceOf(AgentInterface::class, $agent);
6363
}
6464

65-
public function testConstructorInitializesWithProcessors(): void
65+
public function testConstructorInitializesWithProcessors()
6666
{
6767
$platform = $this->createMock(PlatformInterface::class);
6868
$model = $this->createMock(Model::class);
@@ -74,7 +74,7 @@ public function testConstructorInitializesWithProcessors(): void
7474
$this->assertInstanceOf(AgentInterface::class, $agent);
7575
}
7676

77-
public function testConstructorSetsAgentOnAgentAwareProcessors(): void
77+
public function testConstructorSetsAgentOnAgentAwareProcessors()
7878
{
7979
$platform = $this->createMock(PlatformInterface::class);
8080
$model = $this->createMock(Model::class);
@@ -97,7 +97,7 @@ public function setAgent(AgentInterface $agent): void
9797
$this->assertSame($agent, $agentAwareProcessor->agent);
9898
}
9999

100-
public function testConstructorThrowsExceptionForInvalidInputProcessor(): void
100+
public function testConstructorThrowsExceptionForInvalidInputProcessor()
101101
{
102102
$platform = $this->createMock(PlatformInterface::class);
103103
$model = $this->createMock(Model::class);
@@ -110,7 +110,7 @@ public function testConstructorThrowsExceptionForInvalidInputProcessor(): void
110110
new Agent($platform, $model, [$invalidProcessor]);
111111
}
112112

113-
public function testConstructorThrowsExceptionForInvalidOutputProcessor(): void
113+
public function testConstructorThrowsExceptionForInvalidOutputProcessor()
114114
{
115115
$platform = $this->createMock(PlatformInterface::class);
116116
$model = $this->createMock(Model::class);
@@ -123,7 +123,7 @@ public function testConstructorThrowsExceptionForInvalidOutputProcessor(): void
123123
new Agent($platform, $model, [], [$invalidProcessor]);
124124
}
125125

126-
public function testCallProcessesInputThroughProcessors(): void
126+
public function testCallProcessesInputThroughProcessors()
127127
{
128128
$platform = $this->createMock(PlatformInterface::class);
129129
$model = $this->createMock(Model::class);
@@ -149,7 +149,7 @@ public function testCallProcessesInputThroughProcessors(): void
149149
$this->assertSame($result, $actualResult);
150150
}
151151

152-
public function testCallProcessesOutputThroughProcessors(): void
152+
public function testCallProcessesOutputThroughProcessors()
153153
{
154154
$platform = $this->createMock(PlatformInterface::class);
155155
$model = $this->createMock(Model::class);
@@ -175,7 +175,7 @@ public function testCallProcessesOutputThroughProcessors(): void
175175
$this->assertSame($result, $actualResult);
176176
}
177177

178-
public function testCallThrowsExceptionForAudioInputWithoutSupport(): void
178+
public function testCallThrowsExceptionForAudioInputWithoutSupport()
179179
{
180180
$platform = $this->createMock(PlatformInterface::class);
181181
$model = $this->createMock(Model::class);
@@ -192,7 +192,7 @@ public function testCallThrowsExceptionForAudioInputWithoutSupport(): void
192192
$agent->call($messages);
193193
}
194194

195-
public function testCallThrowsExceptionForImageInputWithoutSupport(): void
195+
public function testCallThrowsExceptionForImageInputWithoutSupport()
196196
{
197197
$platform = $this->createMock(PlatformInterface::class);
198198
$model = $this->createMock(Model::class);
@@ -209,7 +209,7 @@ public function testCallThrowsExceptionForImageInputWithoutSupport(): void
209209
$agent->call($messages);
210210
}
211211

212-
public function testCallAllowsAudioInputWithSupport(): void
212+
public function testCallAllowsAudioInputWithSupport()
213213
{
214214
$platform = $this->createMock(PlatformInterface::class);
215215
$model = $this->createMock(Model::class);
@@ -234,7 +234,7 @@ public function testCallAllowsAudioInputWithSupport(): void
234234
$this->assertSame($result, $actualResult);
235235
}
236236

237-
public function testCallAllowsImageInputWithSupport(): void
237+
public function testCallAllowsImageInputWithSupport()
238238
{
239239
$platform = $this->createMock(PlatformInterface::class);
240240
$model = $this->createMock(Model::class);
@@ -258,7 +258,7 @@ public function testCallAllowsImageInputWithSupport(): void
258258
$this->assertSame($result, $actualResult);
259259
}
260260

261-
public function testCallHandlesClientException(): void
261+
public function testCallHandlesClientException()
262262
{
263263
$platform = $this->createMock(PlatformInterface::class);
264264
$model = $this->createMock(Model::class);
@@ -301,7 +301,7 @@ public function getResponse(): HttpResponseInterface
301301
$agent->call($messages);
302302
}
303303

304-
public function testCallHandlesClientExceptionWithEmptyMessage(): void
304+
public function testCallHandlesClientExceptionWithEmptyMessage()
305305
{
306306
$platform = $this->createMock(PlatformInterface::class);
307307
$model = $this->createMock(Model::class);
@@ -339,7 +339,7 @@ public function getResponse(): HttpResponseInterface
339339
$agent->call($messages);
340340
}
341341

342-
public function testCallHandlesHttpException(): void
342+
public function testCallHandlesHttpException()
343343
{
344344
$platform = $this->createMock(PlatformInterface::class);
345345
$model = $this->createMock(Model::class);
@@ -358,7 +358,7 @@ public function testCallHandlesHttpException(): void
358358
$agent->call($messages);
359359
}
360360

361-
public function testCallPassesOptionsToInvoke(): void
361+
public function testCallPassesOptionsToInvoke()
362362
{
363363
$platform = $this->createMock(PlatformInterface::class);
364364
$model = $this->createMock(Model::class);
@@ -380,7 +380,7 @@ public function testCallPassesOptionsToInvoke(): void
380380
$this->assertSame($result, $actualResult);
381381
}
382382

383-
public function testConstructorAcceptsTraversableProcessors(): void
383+
public function testConstructorAcceptsTraversableProcessors()
384384
{
385385
$platform = $this->createMock(PlatformInterface::class);
386386
$model = $this->createMock(Model::class);

src/agent/tests/ChatTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function setUp(): void
4242
$this->chat = new Chat($this->agent, $this->store);
4343
}
4444

45-
public function testItInitiatesChatByClearingAndSavingMessages(): void
45+
public function testItInitiatesChatByClearingAndSavingMessages()
4646
{
4747
$messages = $this->createMock(MessageBagInterface::class);
4848

@@ -56,7 +56,7 @@ public function testItInitiatesChatByClearingAndSavingMessages(): void
5656
$this->chat->initiate($messages);
5757
}
5858

59-
public function testItSubmitsUserMessageAndReturnsAssistantMessage(): void
59+
public function testItSubmitsUserMessageAndReturnsAssistantMessage()
6060
{
6161
$userMessage = Message::ofUser('Hello, how are you?');
6262
$existingMessages = new MessageBag();
@@ -95,7 +95,7 @@ public function testItSubmitsUserMessageAndReturnsAssistantMessage(): void
9595
$this->assertSame($assistantContent, $result->content);
9696
}
9797

98-
public function testItAppendsMessagesToExistingConversation(): void
98+
public function testItAppendsMessagesToExistingConversation()
9999
{
100100
$existingUserMessage = Message::ofUser('What is the weather?');
101101
$existingAssistantMessage = Message::ofAssistant('I cannot provide weather information.');
@@ -136,7 +136,7 @@ public function testItAppendsMessagesToExistingConversation(): void
136136
$this->assertSame($newAssistantContent, $result->content);
137137
}
138138

139-
public function testItHandlesEmptyMessageStore(): void
139+
public function testItHandlesEmptyMessageStore()
140140
{
141141
$userMessage = Message::ofUser('First message');
142142
$emptyMessages = new MessageBag();

src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#[Small]
3333
final class ModelOverrideInputProcessorTest extends TestCase
3434
{
35-
public function testProcessInputWithValidModelOption(): void
35+
public function testProcessInputWithValidModelOption()
3636
{
3737
$gpt = new GPT();
3838
$claude = new Claude();
@@ -44,7 +44,7 @@ public function testProcessInputWithValidModelOption(): void
4444
$this->assertSame($claude, $input->model);
4545
}
4646

47-
public function testProcessInputWithoutModelOption(): void
47+
public function testProcessInputWithoutModelOption()
4848
{
4949
$gpt = new GPT();
5050
$input = new Input($gpt, new MessageBag(), []);
@@ -55,7 +55,7 @@ public function testProcessInputWithoutModelOption(): void
5555
$this->assertSame($gpt, $input->model);
5656
}
5757

58-
public function testProcessInputWithInvalidModelOption(): void
58+
public function testProcessInputWithInvalidModelOption()
5959
{
6060
self::expectException(InvalidArgumentException::class);
6161
self::expectExceptionMessage('Option "model" must be an instance of Symfony\AI\Platform\Model.');

src/agent/tests/InputProcessor/SystemPromptInputProcessorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#[Small]
4444
final class SystemPromptInputProcessorTest extends TestCase
4545
{
46-
public function testProcessInputAddsSystemMessageWhenNoneExists(): void
46+
public function testProcessInputAddsSystemMessageWhenNoneExists()
4747
{
4848
$processor = new SystemPromptInputProcessor('This is a system prompt');
4949

@@ -57,7 +57,7 @@ public function testProcessInputAddsSystemMessageWhenNoneExists(): void
5757
$this->assertSame('This is a system prompt', $messages[0]->content);
5858
}
5959

60-
public function testProcessInputDoesNotAddSystemMessageWhenOneExists(): void
60+
public function testProcessInputDoesNotAddSystemMessageWhenOneExists()
6161
{
6262
$processor = new SystemPromptInputProcessor('This is a system prompt');
6363

@@ -75,7 +75,7 @@ public function testProcessInputDoesNotAddSystemMessageWhenOneExists(): void
7575
$this->assertSame('This is already a system prompt', $messages[0]->content);
7676
}
7777

78-
public function testDoesNotIncludeToolsIfToolboxIsEmpty(): void
78+
public function testDoesNotIncludeToolsIfToolboxIsEmpty()
7979
{
8080
$processor = new SystemPromptInputProcessor(
8181
'This is a system prompt',
@@ -102,7 +102,7 @@ public function execute(ToolCall $toolCall): mixed
102102
$this->assertSame('This is a system prompt', $messages[0]->content);
103103
}
104104

105-
public function testIncludeToolDefinitions(): void
105+
public function testIncludeToolDefinitions()
106106
{
107107
$processor = new SystemPromptInputProcessor(
108108
'This is a system prompt',
@@ -151,7 +151,7 @@ public function execute(ToolCall $toolCall): mixed
151151
PROMPT, $messages[0]->content);
152152
}
153153

154-
public function testWithStringableSystemPrompt(): void
154+
public function testWithStringableSystemPrompt()
155155
{
156156
$processor = new SystemPromptInputProcessor(
157157
new SystemPromptService(),

0 commit comments

Comments
 (0)