8000 Make more data providers static · symfony/symfony@4de90ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 4de90ef

Browse files
committed
Make more data providers static
1 parent e2bd169 commit 4de90ef

File tree

9 files changed

+37
-47
lines changed

9 files changed

+37
-47
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/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public function testFindAllSqlGenerated(AbstractPlatform $platform, string $expe
665665
$connection->findAll(50);
666666
}
667667

668-
public function provideFindAllSqlGeneratedByPlatform(): iterable
668+
public static function provideFindAllSqlGeneratedByPlatform(): iterable
669669
{
670670
yield 'MySQL' => [
671671
class_exists(MySQLPlatform::class) ? new MySQLPlatform() : new MySQL57Platform(),

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/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ public function testDenormalizeBooleanTypesWithNotMatchingData(array $data, stri
10801080
$normalizer->denormalize($data, $type);
10811081
}
10821082

1083-
public function provideBooleanTypesData()
1083+
public static function provideBooleanTypesData(): array
10841084
{
10851085
return [
10861086
[['foo' => true], FalsePropertyDummy::class],

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

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,16 @@ 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(httpClient: $this->getHttpClient()->withOptions([
57+
'base_uri' => 'https://api.us.app.phrase.com/api/v2/projects/PROJECT_ID/',
58+
'headers' => [
59+
'Authorization' => 'token API_TOKEN',
60+
'User-Agent' => 'myProject',
61+
],
62+
]), endpoint: $endpoint);
63+
5664
self::assertSame($expected, (string) $provider);
5765
}
5866

@@ -332,7 +340,7 @@ public function testGetCacheItem(mixed $cachedValue, bool $hasMatchHeader)
332340
$provider->read(['messages'], ['en_GB']);
333341
}
334342

335-
public function cacheItemProvider(): \Generator
343+
public static function cacheItemProvider(): \Generator
336344
{
337345
yield 'null value' => [
338346
'cached_value' => null,
@@ -347,7 +355,7 @@ public function cacheItemProvider(): \Generator
347355
];
348356
}
349357

350-
public function cacheKeyProvider(): \Generator
358+
public static function cacheKeyProvider(): \Generator
351359
{
352360
yield 'sortorder one' => [
353361
'options' => [
@@ -787,7 +795,7 @@ public function testWriteProviderExceptions(int $statusCode, string $expectedExc
787795
$provider->write($bag);
788796
}
789797

790-
public function writeProvider(): \Generator
798+
public static function writeProvider(): \Generator
791799
{
792800
$expectedEnglishXliff = <<<'XLIFF'
793801
<?xml version="1.0" encoding="utf-8"?>
@@ -869,84 +877,66 @@ public function writeProvider(): \Generator
869877
];
870878
}
871879

872-
public function toStringProvider(): \Generator
880+
public static function toStringProvider(): \Generator
873881
{
874882
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-
])),
883+
'endpoint' => null,
882884
'expected' => 'phrase://api.phrase.com',
883885
];
884886

885887
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'),
888+
'endpoint' => 'api.us.app.phrase.com',
893889
'expected' => 'phrase://api.us.app.phrase.com',
894890
];
895891

896892
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'),
893+
'endpoint' => 'api.us.app.phrase.com:8080',
904894
'expected' => 'phrase://api.us.app.phrase.com:8080',
905895
];
906896
}
907897

908-
public function deleteExceptionsProvider(): array
898+
public static function deleteExceptionsProvider(): array
909899
{
910-
return $this->getExceptionResponses(
900+
return self::getExceptionResponses(
911901
exceptionMessage: 'Unable to delete key in phrase.',
912902
loggerMessage: 'Unable to delete key "key.to.delete" in phrase: "provider error".',
913903
statusCode: 500
914904
);
915905
}
916906

917-
public function writeExceptionsProvider(): array
907+
public static function writeExceptionsProvider(): array
918908
{
919-
return $this->getExceptionResponses(
909+
return self::getExceptionResponses(
920910
exceptionMessage: 'Unable to upload translations to phrase.',
921911
loggerMessage: 'Unable to upload translations for domain "messages" to phrase: "provider error".'
922912
);
923913
}
924914

925-
public function createLocalesExceptionsProvider(): array
915+
public static function createLocalesExceptionsProvider(): array
926916
{
927-
return $this->getExceptionResponses(
917+
return self::getExceptionResponses(
928918
exceptionMessage: 'Unable to create locale phrase.',
929919
loggerMessage: 'Unable to create locale "nl-NL" in phrase: "provider error".'
930920
);
931921
}
932922

933-
public function initLocalesExceptionsProvider(): array
923+
public static function initLocalesExceptionsProvider(): array
934924
{
935-
return $this->getExceptionResponses(
925+
return self::getExceptionResponses(
936926
exceptionMessage: 'Unable to get locales from phrase.',
937927
loggerMessage: 'Unable to get locales from phrase: "provider error".'
938928
);
939929
}
940930

941-
public function readProviderExceptionsProvider(): array
931+
public static function readProviderExceptionsProvider(): array
942932
{
943-
return $this->getExceptionResponses(
933+
return self::getExceptionResponses(
944934
exceptionMessage: 'Unable to get translations from phrase.',
945935
loggerMessage: 'Unable to get translations for locale "en_GB" from phrase: "provider error".'
946936
);
947937
}
948938

949-
public function readProvider(): \Generator
939+
public static function readProvider(): \Generator
950940
{
951941
$bag = new TranslatorBag();
952942
$catalogue = new MessageCatalogue('en_GB', [
@@ -1045,7 +1035,7 @@ public function readProvider(): \Generator
10451035
];
10461036
}
10471037

1048-
private function getExceptionResponses(string $exceptionMessage, string $loggerMessage, int $statusCode = 400): array
1038+
private static function getExceptionResponses(string $exceptionMessage, string $loggerMessage, int $statusCode = 400): array
10491039
{
10501040
return [
10511041
'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)
0