Validate XLIFF files in tests using the XSD
This commit is contained in:
parent
043a505fc9
commit
17dfa1d5fc
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Resources;
|
namespace Symfony\Component\Form\Tests\Resources;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Util\Xml\Loader;
|
use Symfony\Component\Translation\Util\XliffUtils;
|
||||||
|
|
||||||
class TranslationFilesTest extends TestCase
|
class TranslationFilesTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -21,13 +21,12 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
$loader = class_exists(Loader::class)
|
$document = new \DOMDocument();
|
||||||
? [new Loader(), 'loadFile']
|
$document->loadXML(file_get_contents($filePath));
|
||||||
: ['PHPUnit\Util\XML', 'loadfile'];
|
|
||||||
|
|
||||||
$loader($filePath, false, false, true);
|
$errors = XliffUtils::validateSchema($document);
|
||||||
|
|
||||||
$this->addToAssertionCount(1);
|
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Core\Tests\Resources;
|
namespace Symfony\Component\Security\Core\Tests\Resources;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Util\Xml\Loader;
|
use Symfony\Component\Translation\Util\XliffUtils;
|
||||||
|
|
||||||
class TranslationFilesTest extends TestCase
|
class TranslationFilesTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -21,13 +21,12 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
$loader = class_exists(Loader::class)
|
$document = new \DOMDocument();
|
||||||
? [new Loader(), 'loadFile']
|
$document->loadXML(file_get_contents($filePath));
|
||||||
: ['PHPUnit\Util\XML', 'loadfile'];
|
|
||||||
|
|
||||||
$loader($filePath, false, false, true);
|
$errors = XliffUtils::validateSchema($document);
|
||||||
|
|
||||||
$this->addToAssertionCount(1);
|
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
"symfony/expression-language": "^3.4|^4.0|^5.0",
|
"symfony/expression-language": "^3.4|^4.0|^5.0",
|
||||||
"symfony/http-foundation": "^3.4|^4.0|^5.0",
|
"symfony/http-foundation": "^3.4|^4.0|^5.0",
|
||||||
"symfony/ldap": "^4.4|^5.0",
|
"symfony/ldap": "^4.4|^5.0",
|
||||||
|
"symfony/translation": "^4.4|^5.0",
|
||||||
"symfony/validator": "^3.4.31|^4.3.4|^5.0",
|
"symfony/validator": "^3.4.31|^4.3.4|^5.0",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Resources;
|
namespace Symfony\Component\Validator\Tests\Resources;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Util\Xml\Loader;
|
use Symfony\Component\Translation\Util\XliffUtils;
|
||||||
|
|
||||||
class TranslationFilesTest extends TestCase
|
class TranslationFilesTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -21,13 +21,12 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
$loader = class_exists(Loader::class)
|
$document = new \DOMDocument();
|
||||||
? [new Loader(), 'loadFile']
|
$document->loadXML(file_get_contents($filePath));
|
||||||
: ['PHPUnit\Util\XML', 'loadfile'];
|
|
||||||
|
|
||||||
$loader($filePath, false, false, true);
|
$errors = XliffUtils::validateSchema($document);
|
||||||
|
|
||||||
$this->addToAssertionCount(1);
|
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
Reference in New Issue
Block a user