TranslationFilesTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\Tests\Resources;
  11. use PHPUnit\Framework\TestCase;
  12. class TranslationFilesTest extends TestCase
  13. {
  14. /**
  15. * @dataProvider provideTranslationFiles
  16. */
  17. public function testTranslationFileIsValid($filePath)
  18. {
  19. if (class_exists('PHPUnit_Util_XML')) {
  20. \PHPUnit_Util_XML::loadfile($filePath, false, false, true);
  21. } else {
  22. \PHPUnit\Util\XML::loadfile($filePath, false, false, true);
  23. }
  24. $this->addToAssertionCount(1);
  25. }
  26. public function provideTranslationFiles()
  27. {
  28. return array_map(
  29. function ($filePath) { return (array) $filePath; },
  30. glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf')
  31. );
  32. }
  33. public function testNorwegianAlias()
  34. {
  35. $this->assertFileEquals(
  36. \dirname(\dirname(__DIR__)).'/Resources/translations/validators.nb.xlf',
  37. \dirname(\dirname(__DIR__)).'/Resources/translations/validators.no.xlf',
  38. 'The NO locale should be an alias for the NB variant of the Norwegian language.'
  39. );
  40. }
  41. }