Skip to content

Commit ff8bb21

Browse files
Merge branch '5.3' into 5.4
* 5.3: [HttpClient] mark test transient [Mime] Fix test [Translation] Fix TranslationPullCommand with ICU translations Allow package-versions-deprecated plugin Update security.lb.xlf [Notifier] Use correct factory for the msteams transport Fix SessionListener without session in request Remove direct dependency on composer/package-versions-deprecated Remove the unused dependency on composer/package-versions-deprecated [Security/Http] Fix cookie clearing on logout [HttpClient] fix checking for recent curl consts
2 parents 8c7affb + 6ef0582 commit ff8bb21

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed

Catalogue/AbstractOperation.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,18 @@ public function __construct(MessageCatalogueInterface $source, MessageCatalogueI
8383
public function getDomains()
8484
{
8585
if (null === $this->domains) {
86-
$this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains())));
86+
$domains = [];
87+
foreach ([$this->source, $this->target] as $catalogue) {
88+
foreach ($catalogue->getDomains() as $domain) {
89+
$domains[$domain] = $domain;
90+
91+
if ($catalogue->all($domainIcu = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX)) {
92+
$domains[$domainIcu] = $domainIcu;
93+
}
94+
}
95+
}
96+
97+
$this->domains = array_values($domains);
8798
}
8899

89100
return $this->domains;

Tests/Catalogue/MergeOperationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testGetResultFromIntlDomain()
5858
$this->assertEquals(
5959
new MessageCatalogue('en', [
6060
'messages' => ['a' => 'old_a', 'b' => 'old_b'],
61-
'messages+intl-icu' => ['d' => 'old_d', 'c' => 'new_c'],
61+
'messages+intl-icu' => ['d' => 'old_d', 'c' => 'new_c', 'a' => 'new_a'],
6262
]),
6363
$this->createOperation(
6464
new MessageCatalogue('en', ['messages' => ['a' => 'old_a', 'b' => 'old_b'], 'messages+intl-icu' => ['d' => 'old_d']]),

Tests/Catalogue/TargetOperationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function testGetResultWithMixedDomains()
7272
$this->assertEquals(
7373
new MessageCatalogue('en', [
7474
'messages' => ['a' => 'old_a'],
75+
'messages+intl-icu' => ['a' => 'new_a'],
7576
]),
7677
$this->createOperation(
7778
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]),
@@ -103,7 +104,7 @@ public function testGetResultWithMixedDomains()
103104
$this->assertEquals(
104105
new MessageCatalogue('en', [
105106
'messages' => ['a' => 'old_a'],
106-
'messages+intl-icu' => ['b' => 'new_b'],
107+
'messages+intl-icu' => ['b' => 'new_b', 'a' => 'new_a'],
107108
]),
108109
$this->createOperation(
109110
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]),

Tests/Command/TranslationPullCommandTest.php

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,27 @@ public function testPullNewXlf12Messages()
4747
{
4848
$arrayLoader = new ArrayLoader();
4949
$filenameEn = $this->createFile();
50+
$filenameEnIcu = $this->createFile(['say_hello' => 'Welcome, {firstname}!'], 'en', 'messages+intl-icu.%locale%.xlf');
5051
$filenameFr = $this->createFile(['note' => 'NOTE'], 'fr');
52+
$filenameFrIcu = $this->createFile(['say_hello' => 'Bonjour, {firstname}!'], 'fr', 'messages+intl-icu.%locale%.xlf');
5153
$locales = ['en', 'fr'];
52-
$domains = ['messages'];
54+
$domains = ['messages', 'messages+intl-icu'];
5355

5456
$providerReadTranslatorBag = new TranslatorBag();
5557
$providerReadTranslatorBag->addCatalogue($arrayLoader->load([
5658
'note' => 'NOTE',
5759
'new.foo' => 'newFoo',
5860
], 'en'));
61+
$providerReadTranslatorBag->addCatalogue($arrayLoader->load([
62+
'say_hello' => 'Welcome, {firstname}!',
63+
], 'en', 'messages+intl-icu'));
5964
$providerReadTranslatorBag->addCatalogue($arrayLoader->load([
6065
'note' => 'NOTE',
6166
'new.foo' => 'nouveauFoo',
6267
], 'fr'));
68+
$providerReadTranslatorBag->addCatalogue($arrayLoader->load([
69+
'say_hello' => 'Bonjour, {firstname}!',
70+
], 'fr', 'messages+intl-icu'));
6371

6472
$provider = $this->createMock(ProviderInterface::class);
6573
$provider->expects($this->once())
@@ -72,9 +80,9 @@ public function testPullNewXlf12Messages()
7280
->willReturn('null://default');
7381

7482
$tester = $this->createCommandTester($provider, $locales, $domains);
75-
$tester->execute(['--locales' => ['en', 'fr'], '--domains' => ['messages']]);
83+
$tester->execute(['--locales' => ['en', 'fr'], '--domains' => ['messages', 'messages+intl-icu']]);
7684

77-
$this->assertStringContainsString('[OK] New translations from "null" has been written locally (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
85+
$this->assertStringContainsString('[OK] New translations from "null" has been written locally (for "en, fr" locale(s), and "messages, messages+intl-icu"', trim($tester->getDisplay()));
7886
$this->assertXmlStringEqualsXmlString(<<<XLIFF
7987
<?xml version="1.0"?>
8088
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
@@ -98,6 +106,23 @@ public function testPullNewXlf12Messages()
98106
, file_get_contents($filenameEn));
99107
$this->assertXmlStringEqualsXmlString(<<<XLIFF
100108
<?xml version="1.0"?>
109+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
110+
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
111+
<header>
112+
<tool tool-id="symfony" tool-name="Symfony"/>
113+
</header>
114+
<body>
115+
<trans-unit id="1IHotcu" resname="say_hello">
116+
<source>say_hello</source>
117+
<target>Welcome, {firstname}!</target>
118+
</trans-unit>
119+
</body>
120+
</file>
121+
</xliff>
122+
XLIFF
123+
, file_get_contents($filenameEnIcu));
124+
$this->assertXmlStringEqualsXmlString(<<<XLIFF
125+
<?xml version="1.0"?>
101126
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
102127
<file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
103128
<header>
@@ -117,6 +142,23 @@ public function testPullNewXlf12Messages()
117142
</xliff>
118143
XLIFF
119144
, file_get_contents($filenameFr));
145+
$this->assertXmlStringEqualsXmlString(<<<XLIFF
146+
<?xml version="1.0"?>
147+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
148+
<file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
149+
<header>
150+
<tool tool-id="symfony" tool-name="Symfony"/>
151+
</header>
152+
<body>
153+
<trans-unit id="1IHotcu" resname="say_hello">
154+
<source>say_hello</source>
155+
<target>Bonjour, {firstname}!</target>
156+
</trans-unit>
157+
</body>
158+
</file>
159+
</xliff>
160+
XLIFF
161+
, file_get_contents($filenameFrIcu));
120162
}
121163

122164
public function testPullNewXlf20Messages()

0 commit comments

Comments
 (0)