Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function read(array $domains, array $locales): TranslatorBag
// Loco forbids concurrent requests, so the requests must be synchronous in order to prevent "429 Too Many Requests" errors.
$response = $this->client->request('GET', \sprintf('export/locale/%s.xlf', rawurlencode($locale)), [
'query' => [
'filter' => $domain,
'filter' => '*' !== $domain ? $domain : '',
'status' => 'translated,blank-translation',
],
'headers' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,7 @@ public static function getResponsesForOneLocaleAndOneDomain(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
$expectedTranslatorBagEn,
];

Expand Down Expand Up @@ -997,8 +996,7 @@ public static function getResponsesForOneLocaleAndOneDomain(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
$expectedTranslatorBagFr,
];
}
Expand Down Expand Up @@ -1049,8 +1047,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
'messages+intl-icu' => <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
Expand All @@ -1066,8 +1063,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
'validators' => <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
Expand All @@ -1087,8 +1083,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
],
'fr' => [
'messages' => <<<'XLIFF'
Expand All @@ -1106,8 +1101,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
'messages+intl-icu' => <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
Expand All @@ -1123,8 +1117,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
'validators' => <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
Expand All @@ -1144,8 +1137,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
</body>
</file>
</xliff>
XLIFF
,
XLIFF,
],
],
$expectedTranslatorBag,
Expand All @@ -1170,4 +1162,32 @@ public static function getResponsesForReadWithLastModified(): \Generator
yield [$locales, $domains, $responseContents, $lastModifieds, $expectedTranslatorBag];
}
}

public function testReadForAllDomains()
{
$loader = $this->getLoader();

$loader
->expects($this->once())
->method('load')
->willReturn($this->createMock(MessageCatalogue::class));

$provider = self::createProvider(
new MockHttpClient([
function (string $method, string $url, array $options = []): ResponseInterface {
$this->assertSame('GET', $method);
$this->assertSame('https://localise.biz/api/export/locale/fr.xlf?filter=&status=translated%2Cblank-translation', $url);
$this->assertSame(['filter' => '', 'status' => 'translated,blank-translation'], $options['query']);

return new MockResponse();
},
], 'https://localise.biz/api/'),
$this->getLoader(),
$this->getLogger(),
$this->getDefaultLocale(),
'localise.biz/api/',
);

$this->translatorBag = $provider->read(['*'], ['fr']);
}
}