From e22b75b2104bdc35c085a6d885510720d487a73f Mon Sep 17 00:00:00 2001 From: "maxime.steinhausser" Date: Tue, 6 Oct 2015 15:25:25 +0200 Subject: [PATCH] [Security] Add test to ensure translation files are synced --- .../Resources/translations/security.tr.xlf | 12 ++-- .../Translation/SyncedTranslationsTest.php | 60 +++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Security/Tests/Core/Translation/SyncedTranslationsTest.php diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf index fbf9b260b05c0..68c44213d18c3 100644 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.tr.xlf @@ -8,7 +8,7 @@ Authentication credentials could not be found. - Yetkilendirme girdileri bulunamadı. + Kimlik bilgileri bulunamadı. Authentication request could not be processed due to a system problem. @@ -16,7 +16,7 @@ Invalid credentials. - Geçersiz girdiler. + Geçersiz kimlik bilgileri. Cookie has already been used by someone else. @@ -32,7 +32,7 @@ Digest nonce has expired. - Derleme zaman aşımı gerçekleşti. + Derleme zaman aşımına uğradı. No authentication provider found to support the authentication token. @@ -44,7 +44,7 @@ No token could be found. - Bilet bulunamadı. + Fiş bulunamadı. Username could not be found. @@ -56,11 +56,11 @@ Credentials have expired. - Girdiler zaman aşımına uğradı. + Kimlik bilgileri zaman aşımına uğradı. Account is disabled. - Hesap devre dışı bırakılmış. + Hesap engellenmiş. Account is locked. diff --git a/src/Symfony/Component/Security/Tests/Core/Translation/SyncedTranslationsTest.php b/src/Symfony/Component/Security/Tests/Core/Translation/SyncedTranslationsTest.php new file mode 100644 index 0000000000000..b5b0dee5d7735 --- /dev/null +++ b/src/Symfony/Component/Security/Tests/Core/Translation/SyncedTranslationsTest.php @@ -0,0 +1,60 @@ +securityRootDir = __DIR__.'/../../../'; + $this->securityTransDir = $this->securityRootDir.'Resources/translations/'; + $this->securityCoreTransDir = $this->securityRootDir.'Core/Resources/translations/'; + } + + public function testTranslationsFoldersAreSynced() + { + $this->assertSame( + $this->getTranslationFilesForDir($this->securityTransDir), + $this->getTranslationFilesForDir($this->securityCoreTransDir) + ); + } + + /** + * @dataProvider translationFilePathsProvider + */ + public function testTranslationsFilesAreSynced($filePath) + { + $originPath = $this->securityCoreTransDir.$filePath; + $expectedPath = $this->securityTransDir.$filePath; + + $this->assertFileEquals($originPath, $expectedPath, sprintf('"%s" and "%s" translation files should not be out of sync.', $originPath, $expectedPath)); + } + + public function translationFilePathsProvider() + { + return array_map(function ($path) { + return array($path); + }, $this->getTranslationFilesForDir($this->securityTransDir)); + } + + private function getTranslationFilesForDir($dir) + { + $filePaths = array(); + foreach (scandir($dir) as $path) { + $file = new \SplFileInfo($path); + if ($file->isDir()) { + continue; + } + if (2 !== substr_count($file->getBasename(), '.') || 0 === preg_match('/\.\w+$/', $file->getBasename())) { + continue; + }; + + $filePaths[] = $path; + } + + return $filePaths; + } +}