@@ -51,8 +51,10 @@ class PhraseProviderTest extends TestCase
51
51
/**
52
52
* @dataProvider toStringProvider
53
53
*/
54
- public function testToString (ProviderInterface $ provider , string $ expected )
54
+ public function testToString (? string $ endpoint , string $ expected )
55
55
{
56
+ $ provider = $ this ->createProvider (endpoint: $ endpoint );
57
+
56
58
self ::assertSame ($ expected , (string ) $ provider );
57
59
}
58
60
@@ -332,7 +334,7 @@ public function testGetCacheItem(mixed $cachedValue, bool $hasMatchHeader)
332
334
$ provider ->read (['messages ' ], ['en_GB ' ]);
333
335
}
334
336
335
- public function cacheItemProvider (): \Generator
337
+ public static function cacheItemProvider (): \Generator
336
338
{
337
339
yield 'null value ' => [
338
340
'cached_value ' => null ,
@@ -347,7 +349,7 @@ public function cacheItemProvider(): \Generator
347
349
];
348
350
}
349
351
350
- public function cacheKeyProvider (): \Generator
352
+ public static function cacheKeyProvider (): \Generator
351
353
{
352
354
yield 'sortorder one ' => [
353
355
'options ' => [
@@ -787,7 +789,7 @@ public function testWriteProviderExceptions(int $statusCode, string $expectedExc
787
789
$ provider ->write ($ bag );
788
790
}
789
791
790
- public function writeProvider (): \Generator
792
+ public static function writeProvider (): \Generator
791
793
{
792
794
$ expectedEnglishXliff = <<<'XLIFF'
793
795
<?xml version="1.0" encoding="utf-8"?>
@@ -869,84 +871,66 @@ public function writeProvider(): \Generator
869
871
];
870
872
}
871
873
872
- public function toStringProvider (): \Generator
874
+ public static function toStringProvider (): \Generator
873
875
{
874
876
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 ,
882
878
'expected ' => 'phrase://api.phrase.com ' ,
883
879
];
884
880
885
881
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 ' ,
893
883
'expected ' => 'phrase://api.us.app.phrase.com ' ,
894
884
];
895
885
896
886
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 ' ,
904
888
'expected ' => 'phrase://api.us.app.phrase.com:8080 ' ,
905
889
];
906
890
}
907
891
908
- public function deleteExceptionsProvider (): array
892
+ public static function deleteExceptionsProvider (): array
909
893
{
910
- return $ this -> getExceptionResponses (
894
+ return self :: getExceptionResponses (
911
895
exceptionMessage: 'Unable to delete key in phrase. ' ,
912
896
loggerMessage: 'Unable to delete key "key.to.delete" in phrase: "provider error". ' ,
913
897
statusCode: 500
914
898
);
915
899
}
916
900
917
- public function writeExceptionsProvider (): array
901
+ public static function writeExceptionsProvider (): array
918
902
{
919
- return $ this -> getExceptionResponses (
903
+ return self :: getExceptionResponses (
920
904
exceptionMessage: 'Unable to upload translations to phrase. ' ,
921
905
loggerMessage: 'Unable to upload translations for domain "messages" to phrase: "provider error". '
922
906
);
923
907
}
924
908
925
- public function createLocalesExceptionsProvider (): array
909
+ public static function createLocalesExceptionsProvider (): array
926
910
{
927
- return $ this -> getExceptionResponses (
911
+ return self :: getExceptionResponses (
928
912
exceptionMessage: 'Unable to create locale phrase. ' ,
929
913
loggerMessage: 'Unable to create locale "nl-NL" in phrase: "provider error". '
930
914
);
931
915
}
932
916
933
- public function initLocalesExceptionsProvider (): array
917
+ public static function initLocalesExceptionsProvider (): array
934
918
{
935
- return $ this -> getExceptionResponses (
919
+ return self :: getExceptionResponses (
936
920
exceptionMessage: 'Unable to get locales from phrase. ' ,
937
921
loggerMessage: 'Unable to get locales from phrase: "provider error". '
938
922
);
939
923
}
940
924
941
- public function readProviderExceptionsProvider (): array
925
+ public static function readProviderExceptionsProvider (): array
942
926
{
943
- return $ this -> getExceptionResponses (
927
+ return self :: getExceptionResponses (
944
928
exceptionMessage: 'Unable to get translations from phrase. ' ,
945
929
loggerMessage: 'Unable to get translations for locale "en_GB" from phrase: "provider error". '
946
930
);
947
931
}
948
932
949
- public function readProvider (): \Generator
933
+ public static function readProvider (): \Generator
950
934
{
951
935
$ bag = new TranslatorBag ();
952
936
$ catalogue = new MessageCatalogue ('en_GB ' , [
@@ -1045,7 +1029,7 @@ public function readProvider(): \Generator
1045
1029
];
1046
1030
}
1047
1031
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
1049
1033
{
1050
1034
return [
1051
1035
'bad request ' => [
0 commit comments