Skip to content

Commit 5d81736

Browse files
committed
Merge branch '5.1' into 5.x
* 5.1: Validate XLIFF files in tests using the XSD
2 parents c22baf5 + e2c808f commit 5d81736

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Tests/Resources/TranslationFilesTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Tests\Resources;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use PHPUnit\Util\Xml\Loader;
15+
use Symfony\Component\Translation\Util\XliffUtils;
1616

1717
class TranslationFilesTest extends TestCase
1818
{
@@ -21,13 +21,12 @@ class TranslationFilesTest extends TestCase
2121
*/
2222
public function testTranslationFileIsValid($filePath)
2323
{
24-
$loader = class_exists(Loader::class)
25-
? [new Loader(), 'loadFile']
26-
: ['PHPUnit\Util\XML', 'loadfile'];
24+
$document = new \DOMDocument();
25+
$document->loadXML(file_get_contents($filePath));
2726

28-
$loader($filePath, false, false, true);
27+
$errors = XliffUtils::validateSchema($document);
2928

30-
$this->addToAssertionCount(1);
29+
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
3130
}
3231

3332
public function provideTranslationFiles()

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"symfony/expression-language": "^4.4|^5.0",
2929
"symfony/http-foundation": "^4.4|^5.0",
3030
"symfony/ldap": "^4.4|^5.0",
31+
"symfony/translation": "^4.4|^5.0",
3132
"symfony/validator": "^5.2",
3233
"psr/log": "~1.0"
3334
},

0 commit comments

Comments
 (0)