Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security] sync translations and add a test for it
- Loading branch information
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Tests; | ||
|
||
use Symfony\Component\Finder\Finder; | ||
|
||
class TranslationSyncStatusTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider getTranslationDirectoriesData | ||
*/ | ||
public function testTranslationFileIsNotMissingInCore($dir1, $dir2) | ||
{ | ||
$finder = new Finder(); | ||
$files = $finder->in($dir1)->files(); | ||
|
||
foreach ($files as $file) { | ||
$this->assertFileExists($dir2.'/'.$file->getFilename(), 'Missing file '.$file->getFilename().' in directory '.$dir2); | ||
} | ||
} | ||
|
||
public function getTranslationDirectoriesData() | ||
{ | ||
$legacyTranslationsDir = $this->getLegacyTranslationsDirectory(); | ||
$coreTranslationsDir = $this->getCoreTranslationsDirectory(); | ||
|
||
return array( | ||
'file-not-missing-in-core' => array($legacyTranslationsDir, $coreTranslationsDir), | ||
'file-not-added-in-core' => array($coreTranslationsDir, $legacyTranslationsDir), | ||
); | ||
} | ||
|
||
public function testFileContentsAreEqual() | ||
{ | ||
$finder = new Finder(); | ||
$files = $finder->in($this->getLegacyTranslationsDirectory())->files(); | ||
|
||
foreach ($files as $file) { | ||
$coreFile = $this->getCoreTranslationsDirectory().'/'.$file->getFilename(); | ||
|
||
$this->assertFileEquals($file->getRealPath(), $coreFile, $file.' and '.$coreFile.' have equal content.'); | ||
} | ||
} | ||
|
||
private function getLegacyTranslationsDirectory() | ||
{ | ||
return __DIR__.'/../Resources/translations'; | ||
} | ||
|
||
private function getCoreTranslationsDirectory() | ||
{ | ||
return __DIR__.'/../Core/Resources/translations'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters