TranslationSyncStatusTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Security\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Finder\Finder;
  13. class TranslationSyncStatusTest extends TestCase
  14. {
  15. /**
  16. * @dataProvider getTranslationDirectoriesData
  17. */
  18. public function testTranslationFileIsNotMissingInCore($dir1, $dir2)
  19. {
  20. $finder = new Finder();
  21. $files = $finder->in($dir1)->files();
  22. foreach ($files as $file) {
  23. $this->assertFileExists($dir2.'/'.$file->getFilename(), 'Missing file '.$file->getFilename().' in directory '.$dir2);
  24. }
  25. }
  26. public function getTranslationDirectoriesData()
  27. {
  28. $legacyTranslationsDir = $this->getLegacyTranslationsDirectory();
  29. $coreTranslationsDir = $this->getCoreTranslationsDirectory();
  30. return array(
  31. 'file-not-missing-in-core' => array($legacyTranslationsDir, $coreTranslationsDir),
  32. 'file-not-added-in-core' => array($coreTranslationsDir, $legacyTranslationsDir),
  33. );
  34. }
  35. public function testFileContentsAreEqual()
  36. {
  37. $finder = new Finder();
  38. $files = $finder->in($this->getLegacyTranslationsDirectory())->files();
  39. foreach ($files as $file) {
  40. $coreFile = $this->getCoreTranslationsDirectory().'/'.$file->getFilename();
  41. $this->assertFileEquals($file->getRealPath(), $coreFile, $file.' and '.$coreFile.' have equal content.');
  42. }
  43. }
  44. private function getLegacyTranslationsDirectory()
  45. {
  46. return __DIR__.'/../Resources/translations';
  47. }
  48. private function getCoreTranslationsDirectory()
  49. {
  50. return __DIR__.'/../Core/Resources/translations';
  51. }
  52. }