Skip to content

Commit 7e8c7d9

Browse files
committed
minor symfony#58323 Make more data providers static (derrabus)
This PR was merged into the 6.4 branch. Discussion ---------- Make more data providers static | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | N/A | License | MIT Data providers must be public and static in PHPUnit 11. Commits ------- c0d5be6 Make more data providers static
2 parents 3d8dc95 + c0d5be6 commit 7e8c7d9

File tree

7 files changed

+29
-45
lines changed

7 files changed

+29
-45
lines changed

src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testCanUseParam()
7474
/**
7575
* @see testCanOnlySetOneParameter
7676
*/
77-
private static function provideMultipleParameters(): iterable
77+
public static function provideMultipleParameters(): iterable
7878
{
7979
yield [['service' => 'id', 'expression' => 'expr']];
8080

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testConstructorShouldThrowExceptionForMissingOptions(array $opti
9898
new MongoDbSessionHandler($this->manager, $options);
9999
}
100100

101-
public function provideInvalidOptions()
101+
public static function provideInvalidOptions(): iterable
102102
{
103103
yield 'empty' => [[]];
104104
yield 'collection missing' => [['database' => 'foo']];

src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseHeaderLocationSameTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testConstraintSuccess(string $requestUrl, ?string $location, str
3636
self::assertTrue($constraint->evaluate($response, '', true));
3737
}
3838

39-
public function provideSuccessCases(): iterable
39+
public static function provideSuccessCases(): iterable
4040
{
4141
yield ['http://example.com', 'http://example.com', 'http://example.com'];
4242
yield ['http://example.com', 'http://example.com', '//example.com'];
@@ -112,7 +112,7 @@ public function testConstraintFailure(string $requestUrl, ?string $location, str
112112
$constraint->evaluate($response);
113113
}
114114

115-
public function provideFailureCases(): iterable
115+
public static function provideFailureCases(): iterable
116116
{
117117
yield ['http://example.com', null, 'http://example.com'];
118118
yield ['http://example.com', null, '//example.com'];

src/Symfony/Component/Mime/Tests/MessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function testEnsureValidity(array $headers, ?string $exceptionClass, ?str
306306
$m->ensureValidity();
307307
}
308308

309-
public function ensureValidityProvider()
309+
public static function ensureValidityProvider(): array
310310
{
311311
return [
312312
'Valid address fields' => [

src/Symfony/Component/Security/Http/Tests/Authenticator/AccessTokenAuthenticatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function testAccessTokenHeaderRegex(string $input, ?string $expectedToken
177177
$this->assertEquals($expectedToken, $token);
178178
}
179179

180-
public function provideAccessTokenHeaderRegex(): array
180+
public static function provideAccessTokenHeaderRegex(): array
181181
{
182182
return [
183183
['Bearer token', 'token'],

src/Symfony/Component/Translation/Bridge/Phrase/Tests/PhraseProviderTest.php

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ class PhraseProviderTest extends TestCase
5151
/**
5252
* @dataProvider toStringProvider
5353
*/
54-
public function testToString(ProviderInterface $provider, string $expected)
54+
public function testToString(?string $endpoint, string $expected)
5555
{
56+
$provider = $this->createProvider(endpoint: $endpoint);
57+
5658
self::assertSame($expected, (string) $provider);
5759
}
5860

@@ -332,7 +334,7 @@ public function testGetCacheItem(mixed $cachedValue, bool $hasMatchHeader)
332334
$provider->read(['messages'], ['en_GB']);
333335
}
334336

335-
public function cacheItemProvider(): \Generator
337+
public static function cacheItemProvider(): \Generator
336338
{
337339
yield 'null value' => [
338340
'cached_value' => null,
@@ -347,7 +349,7 @@ public function cacheItemProvider(): \Generator
347349
];
348350
}
349351

350-
public function cacheKeyProvider(): \Generator
352+
public static function cacheKeyProvider(): \Generator
351353
{
352354
yield 'sortorder one' => [
353355
'options' => [
@@ -787,7 +789,7 @@ public function testWriteProviderExceptions(int $statusCode, string $expectedExc
787789
$provider->write($bag);
788790
}
789791

790-
public function writeProvider(): \Generator
792+
public static function writeProvider(): \Generator
791793
{
792794
$expectedEnglishXliff = <<<'XLIFF'
793795
<?xml version="1.0" encoding="utf-8"?>
@@ -869,84 +871,66 @@ public function writeProvider(): \Generator
869871
];
870872
}
871873

872-
public function toStringProvider(): \Generator
874+
public static function toStringProvider(): \Generator
873875
{
874876
yield 'default endpoint' => [
875-
'provider' => $this->createProvider(httpClient: $this->getHttpClient()->withOptions([
876-
'base_uri' => 'https://api.phrase.com/api/v2/projects/PROJECT_ID/',
877-
'headers' => [
878-
'Authorization' => 'token API_TOKEN',
879-
'User-Agent' => 'myProject',
880-
],
881-
])),
877+
'endpoint' => null,
882878
'expected' => 'phrase://api.phrase.com',
883879
];
884880

885881
yield 'custom endpoint' => [
886-
'provider' => $this->createProvider(httpClient: $this->getHttpClient()->withOptions([
887-
'base_uri' => 'https://api.us.app.phrase.com/api/v2/projects/PROJECT_ID/',
888-
'headers' => [
889-
'Authorization' => 'token API_TOKEN',
890-
'User-Agent' => 'myProject',
891-
],
892-
]), endpoint: 'api.us.app.phrase.com'),
882+
'endpoint' => 'api.us.app.phrase.com',
893883
'expected' => 'phrase://api.us.app.phrase.com',
894884
];
895885

896886
yield 'custom endpoint with port' => [
897-
'provider' => $this->createProvider(httpClient: $this->getHttpClient()->withOptions([
898-
'base_uri' => 'https://api.us.app.phrase.com:8080/api/v2/projects/PROJECT_ID/',
899-
'headers' => [
900-
'Authorization' => 'token API_TOKEN',
901-
'User-Agent' => 'myProject',
902-
],
903-
]), endpoint: 'api.us.app.phrase.com:8080'),
887+
'endpoint' => 'api.us.app.phrase.com:8080',
904888
'expected' => 'phrase://api.us.app.phrase.com:8080',
905889
];
906890
}
907891

908-
public function deleteExceptionsProvider(): array
892+
public static function deleteExceptionsProvider(): array
909893
{
910-
return $this->getExceptionResponses(
894+
return self::getExceptionResponses(
911895
exceptionMessage: 'Unable to delete key in phrase.',
912896
loggerMessage: 'Unable to delete key "key.to.delete" in phrase: "provider error".',
913897
statusCode: 500
914898
);
915899
}
916900

917-
public function writeExceptionsProvider(): array
901+
public static function writeExceptionsProvider(): array
918902
{
919-
return $this->getExceptionResponses(
903+
return self::getExceptionResponses(
920904
exceptionMessage: 'Unable to upload translations to phrase.',
921905
loggerMessage: 'Unable to upload translations for domain "messages" to phrase: "provider error".'
922906
);
923907
}
924908

925-
public function createLocalesExceptionsProvider(): array
909+
public static function createLocalesExceptionsProvider(): array
926910
{
927-
return $this->getExceptionResponses(
911+
return self::getExceptionResponses(
928912
exceptionMessage: 'Unable to create locale phrase.',
929913
loggerMessage: 'Unable to create locale "nl-NL" in phrase: "provider error".'
930914
);
931915
}
932916

933-
public function initLocalesExceptionsProvider(): array
917+
public static function initLocalesExceptionsProvider(): array
934918
{
935-
return $this->getExceptionResponses(
919+
return self::getExceptionResponses(
936920
exceptionMessage: 'Unable to get locales from phrase.',
937921
loggerMessage: 'Unable to get locales from phrase: "provider error".'
938922
);
939923
}
940924

941-
public function readProviderExceptionsProvider(): array
925+
public static function readProviderExceptionsProvider(): array
942926
{
943-
return $this->getExceptionResponses(
927+
return self::getExceptionResponses(
944928
exceptionMessage: 'Unable to get translations from phrase.',
945929
loggerMessage: 'Unable to get translations for locale "en_GB" from phrase: "provider error".'
946930
);
947931
}
948932

949-
public function readProvider(): \Generator
933+
public static function readProvider(): \Generator
950934
{
951935
$bag = new TranslatorBag();
952936
$catalogue = new MessageCatalogue('en_GB', [
@@ -1045,7 +1029,7 @@ public function readProvider(): \Generator
10451029
];
10461030
}
10471031

1048-
private function getExceptionResponses(string $exceptionMessage, string $loggerMessage, int $statusCode = 400): array
1032+
private static function getExceptionResponses(string $exceptionMessage, string $loggerMessage, int $statusCode = 400): array
10491033
{
10501034
return [
10511035
'bad request' => [

src/Symfony/Component/Validator/Tests/Constraints/CssColorValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function testInvalidHSLA($cssColor)
426426
->assertRaised();
427427
}
428428

429-
public function getInvalidHSLA(): array
429+
public static function getInvalidHSLA(): array
430430
{
431431
return [['hsla(1000, 1000%, 20000%, 999)'], ['hsla(-100, -10%, -2%, 999)'], ['hsla(a, b, c, d)'], ['hsla(a, b%, c%, d)'], ['hsla( 9 99% , 99 9% , 9 %']];
432432
}

0 commit comments

Comments
 (0)