Skip to content

Commit 3525de5

Browse files
committed
minor symfony#58328 Fix named arguments in data providers (derrabus)
This PR was merged into the 6.4 branch. Discussion ---------- Fix named arguments in data providers | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | N/A | License | MIT If a data provider returns data sets with strings keys, PHPUnit 9 would simply discard those keys. PHPUnit 11 however supports named arguments, so the keys are actually matches to parameter names. This PR fixes data providers where the keys of the data sets were not consistent with the names of the parameters of the test cases those providers were applied to. Commits ------- cb6b157 Fix named arguments in data providers
2 parents 7e8c7d9 + cb6b157 commit 3525de5

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

src/Symfony/Component/HtmlSanitizer/Tests/TextSanitizer/UrlSanitizerTest.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testSanitize(?string $input, ?array $allowedSchemes, ?array $all
2424
$this->assertSame($expected, UrlSanitizer::sanitize($input, $allowedSchemes, $forceHttps, $allowedHosts, $allowRelative));
2525
}
2626

27-
public static function provideSanitize()
27+
public static function provideSanitize(): iterable
2828
{
2929
// Simple accepted cases
3030
yield [
@@ -33,7 +33,7 @@ public static function provideSanitize()
3333
'allowedHosts' => null,
3434
'forceHttps' => false,
3535
'allowRelative' => false,
36-
'output' => null,
36+
'expected' => null,
3737
];
3838

3939
yield [
@@ -42,7 +42,7 @@ public static function provideSanitize()
4242
'allowedHosts' => null,
4343
'forceHttps' => false,
4444
'allowRelative' => false,
45-
'output' => null,
45+
'expected' => null,
4646
];
4747

4848
yield [
@@ -51,7 +51,7 @@ public static function provideSanitize()
5151
'allowedHosts' => null,
5252
'forceHttps' => false,
5353
'allowRelative' => false,
54-
'output' => 'http://trusted.com/link.php',
54+
'expected' => 'http://trusted.com/link.php',
5555
];
5656

5757
yield [
@@ -60,7 +60,7 @@ public static function provideSanitize()
6060
'allowedHosts' => null,
6161
'forceHttps' => false,
6262
'allowRelative' => false,
63-
'output' => 'https://trusted.com/link.php',
63+
'expected' => 'https://trusted.com/link.php',
6464
];
6565

6666
yield [
@@ -69,7 +69,7 @@ public static function provideSanitize()
6969
'allowedHosts' => null,
7070
'forceHttps' => false,
7171
'allowRelative' => false,
72-
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
72+
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
7373
];
7474

7575
yield [
@@ -78,7 +78,7 @@ public static function provideSanitize()
7878
'allowedHosts' => null,
7979
'forceHttps' => false,
8080
'allowRelative' => false,
81-
'output' => 'https://trusted.com/link.php',
81+
'expected' => 'https://trusted.com/link.php',
8282
];
8383

8484
yield [
@@ -87,7 +87,7 @@ public static function provideSanitize()
8787
'allowedHosts' => ['trusted.com'],
8888
'forceHttps' => false,
8989
'allowRelative' => false,
90-
'output' => 'https://trusted.com/link.php',
90+
'expected' => 'https://trusted.com/link.php',
9191
];
9292

9393
yield [
@@ -96,7 +96,7 @@ public static function provideSanitize()
9696
'allowedHosts' => ['trusted.com'],
9797
'forceHttps' => false,
9898
'allowRelative' => false,
99-
'output' => 'http://trusted.com/link.php',
99+
'expected' => 'http://trusted.com/link.php',
100100
];
101101

102102
yield [
@@ -105,7 +105,7 @@ public static function provideSanitize()
105105
'allowedHosts' => null,
106106
'forceHttps' => false,
107107
'allowRelative' => false,
108-
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
108+
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
109109
];
110110

111111
// Simple filtered cases
@@ -115,7 +115,7 @@ public static function provideSanitize()
115115
'allowedHosts' => null,
116116
'forceHttps' => false,
117117
'allowRelative' => false,
118-
'output' => null,
118+
'expected' => null,
119119
];
120120

121121
yield [
@@ -124,7 +124,7 @@ public static function provideSanitize()
124124
'allowedHosts' => null,
125125
'forceHttps' => false,
126126
'allowRelative' => false,
127-
'output' => null,
127+
'expected' => null,
128128
];
129129

130130
yield [
@@ -133,7 +133,7 @@ public static function provideSanitize()
133133
'allowedHosts' => null,
134134
'forceHttps' => false,
135135
'allowRelative' => true,
136-
'output' => 'http:link.php',
136+
'expected' => 'http:link.php',
137137
];
138138

139139
yield [
@@ -142,7 +142,7 @@ public static function provideSanitize()
142142
'allowedHosts' => ['trusted.com'],
143143
'forceHttps' => false,
144144
'allowRelative' => false,
145-
'output' => null,
145+
'expected' => null,
146146
];
147147

148148
yield [
@@ -151,7 +151,7 @@ public static function provideSanitize()
151151
'allowedHosts' => null,
152152
'forceHttps' => false,
153153
'allowRelative' => false,
154-
'output' => null,
154+
'expected' => null,
155155
];
156156

157157
yield [
@@ -160,7 +160,7 @@ public static function provideSanitize()
160160
'allowedHosts' => ['trusted.com'],
161161
'forceHttps' => false,
162162
'allowRelative' => false,
163-
'output' => null,
163+
'expected' => null,
164164
];
165165

166166
yield [
@@ -169,7 +169,7 @@ public static function provideSanitize()
169169
'allowedHosts' => ['trusted.com'],
170170
'forceHttps' => false,
171171
'allowRelative' => false,
172-
'output' => null,
172+
'expected' => null,
173173
];
174174

175175
yield [
@@ -178,7 +178,7 @@ public static function provideSanitize()
178178
'allowedHosts' => null,
179179
'forceHttps' => false,
180180
'allowRelative' => false,
181-
'output' => null,
181+
'expected' => null,
182182
];
183183

184184
yield [
@@ -187,7 +187,7 @@ public static function provideSanitize()
187187
'allowedHosts' => ['trusted.com'],
188188
'forceHttps' => false,
189189
'allowRelative' => false,
190-
'output' => null,
190+
'expected' => null,
191191
];
192192

193193
// Allow null host (data scheme for instance)
@@ -197,7 +197,7 @@ public static function provideSanitize()
197197
'allowedHosts' => ['trusted.com', null],
198198
'forceHttps' => false,
199199
'allowRelative' => false,
200-
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
200+
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
201201
];
202202

203203
// Force HTTPS
@@ -207,7 +207,7 @@ public static function provideSanitize()
207207
'allowedHosts' => ['trusted.com'],
208208
'forceHttps' => true,
209209
'allowRelative' => false,
210-
'output' => 'https://trusted.com/link.php',
210+
'expected' => 'https://trusted.com/link.php',
211211
];
212212

213213
yield [
@@ -216,7 +216,7 @@ public static function provideSanitize()
216216
'allowedHosts' => ['trusted.com'],
217217
'forceHttps' => true,
218218
'allowRelative' => false,
219-
'output' => 'https://trusted.com/link.php',
219+
'expected' => 'https://trusted.com/link.php',
220220
];
221221

222222
yield [
@@ -225,7 +225,7 @@ public static function provideSanitize()
225225
'allowedHosts' => null,
226226
'forceHttps' => true,
227227
'allowRelative' => false,
228-
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
228+
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
229229
];
230230

231231
yield [
@@ -234,7 +234,7 @@ public static function provideSanitize()
234234
'allowedHosts' => ['trusted.com', null],
235235
'forceHttps' => true,
236236
'allowRelative' => false,
237-
'output' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
237+
'expected' => 'data:text/plain;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
238238
];
239239

240240
// Domain matching
@@ -244,7 +244,7 @@ public static function provideSanitize()
244244
'allowedHosts' => ['trusted.com'],
245245
'forceHttps' => false,
246246
'allowRelative' => false,
247-
'output' => 'https://subdomain.trusted.com/link.php',
247+
'expected' => 'https://subdomain.trusted.com/link.php',
248248
];
249249

250250
yield [
@@ -253,7 +253,7 @@ public static function provideSanitize()
253253
'allowedHosts' => ['trusted.com'],
254254
'forceHttps' => false,
255255
'allowRelative' => false,
256-
'output' => null,
256+
'expected' => null,
257257
];
258258

259259
yield [
@@ -262,7 +262,7 @@ public static function provideSanitize()
262262
'allowedHosts' => ['trusted.com'],
263263
'forceHttps' => false,
264264
'allowRelative' => false,
265-
'output' => 'https://deep.subdomain.trusted.com/link.php',
265+
'expected' => 'https://deep.subdomain.trusted.com/link.php',
266266
];
267267

268268
yield [
@@ -271,7 +271,7 @@ public static function provideSanitize()
271271
'allowedHosts' => ['trusted.com'],
272272
'forceHttps' => false,
273273
'allowRelative' => false,
274-
'output' => null,
274+
'expected' => null,
275275
];
276276

277277
// Allow relative
@@ -281,7 +281,7 @@ public static function provideSanitize()
281281
'allowedHosts' => ['trusted.com'],
282282
'forceHttps' => true,
283283
'allowRelative' => true,
284-
'output' => '/link.php',
284+
'expected' => '/link.php',
285285
];
286286

287287
yield [
@@ -290,7 +290,7 @@ public static function provideSanitize()
290290
'allowedHosts' => ['trusted.com'],
291291
'forceHttps' => true,
292292
'allowRelative' => false,
293-
'output' => null,
293+
'expected' => null,
294294
];
295295
}
296296

src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public function testMatchingUrls(string $regexp, string $url, array $options)
4949
$this->assertSame($options[$regexp]['case'], $requestedOptions['case']);
5050
}
5151

52-
public static function provideMatchingUrls()
52+
public static function provideMatchingUrls(): iterable
5353
{
5454
$defaultOptions = [
5555
'.*/foo-bar' => ['case' => 1],
5656
'.*' => ['case' => 2],
5757
];
5858

59-
yield ['regexp' => '.*/foo-bar', 'url' => 'http://example.com/foo-bar', 'default_options' => $defaultOptions];
60-
yield ['regexp' => '.*', 'url' => 'http://example.com/bar-foo', 'default_options' => $defaultOptions];
61-
yield ['regexp' => '.*', 'url' => 'http://example.com/foobar', 'default_options' => $defaultOptions];
59+
yield ['regexp' => '.*/foo-bar', 'url' => 'http://example.com/foo-bar', 'options' => $defaultOptions];
60+
yield ['regexp' => '.*', 'url' => 'http://example.com/bar-foo', 'options' => $defaultOptions];
61+
yield ['regexp' => '.*', 'url' => 'http://example.com/foobar', 'options' => $defaultOptions];
6262
}
6363

6464
public function testMatchingUrlsAndOptions()

src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public function testSendFileByFileIdWithOptions(
623623
}
624624

625625
/**
626-
* @return array<array<string, array{messageOptions: TelegramOptions, endpoint: string, fileOption: string, expectedBody: array<mixed>, responseContent: array<mixed>}>>
626+
* @return array<array<string, array{messageOptions: TelegramOptions, endpoint: string, fileOption: string, expectedParameters: array<mixed>, responseContent: array<mixed>}>>
627627
*/
628628
public static function sendFileByUploadProvider(): array
629629
{
@@ -632,7 +632,7 @@ public static function sendFileByUploadProvider(): array
632632
'messageOptions' => (new TelegramOptions())->uploadPhoto(self::FIXTURE_FILE)->hasSpoiler(true),
633633
'endpoint' => 'sendPhoto',
634634
'fileOption' => 'photo',
635-
'expectedBody' => [
635+
'expectedParameters' => [
636636
'has_spoiler' => true,
637637
'chat_id' => 'testChannel',
638638
'parse_mode' => 'MarkdownV2',
@@ -654,7 +654,7 @@ public static function sendFileByUploadProvider(): array
654654
'messageOptions' => (new TelegramOptions())->uploadVideo(self::FIXTURE_FILE),
655655
'endpoint' => 'sendVideo',
656656
'fileOption' => 'video',
657-
'expectedBody' => [
657+
'expectedParameters' => [
658658
'chat_id' => 'testChannel',
659659
'parse_mode' => 'MarkdownV2',
660660
'video' => self::FIXTURE_FILE,
@@ -673,7 +673,7 @@ public static function sendFileByUploadProvider(): array
673673
'messageOptions' => (new TelegramOptions())->uploadAnimation(self::FIXTURE_FILE),
674674
'endpoint' => 'sendAnimation',
675675
'fileOption' => 'animation',
676-
'expectedBody' => [
676+
'expectedParameters' => [
677677
'chat_id' => 'testChannel',
678678
'parse_mode' => 'MarkdownV2',
679679
'animation' => self::FIXTURE_FILE,
@@ -692,7 +692,7 @@ public static function sendFileByUploadProvider(): array
692692
'messageOptions' => (new TelegramOptions())->uploadAudio(self::FIXTURE_FILE),
693693
'endpoint' => 'sendAudio',
694694
'fileOption' => 'audio',
695-
'expectedBody' => [
695+
'expectedParameters' => [
696696
'chat_id' => 'testChannel',
697697
'parse_mode' => 'MarkdownV2',
698698
'audio' => self::FIXTURE_FILE,
@@ -711,7 +711,7 @@ public static function sendFileByUploadProvider(): array
711711
'messageOptions' => (new TelegramOptions())->uploadDocument(self::FIXTURE_FILE),
712712
'endpoint' => 'sendDocument',
713713
'fileOption' => 'document',
714-
'expectedBody' => [
714+
'expectedParameters' => [
715715
'chat_id' => 'testChannel',
716716
'parse_mode' => 'MarkdownV2',
717717
'document' => self::FIXTURE_FILE,
@@ -732,7 +732,7 @@ public static function sendFileByUploadProvider(): array
732732
'messageOptions' => (new TelegramOptions())->uploadSticker(self::FIXTURE_FILE, '🤖'),
733733
'endpoint' => 'sendSticker',
734734
'fileOption' => 'sticker',
735-
'expectedBody' => [
735+
'expectedParameters' => [
736736
'emoji' => '🤖',
737737
'chat_id' => 'testChannel',
738738
'parse_mode' => 'MarkdownV2',
@@ -757,7 +757,7 @@ public static function sendFileByUploadProvider(): array
757757
'messageOptions' => (new TelegramOptions())->uploadSticker(self::FIXTURE_FILE),
758758
'endpoint' => 'sendSticker',
759759
'fileOption' => 'sticker',
760-
'expectedBody' => [
760+
'expectedParameters' => [
761761
'chat_id' => 'testChannel',
762762
'parse_mode' => 'MarkdownV2',
763763
'sticker' => self::FIXTURE_FILE,

src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function provideObjectsAndLogs(): \Generator
116116
'result' => true,
117117
'voterDetails' => [],
118118
]],
119-
'attributes' => [12],
119+
[12],
120120
12345,
121121
[],
122122
true,

0 commit comments

Comments
 (0)