8000 [Security] Add test to ensure translation files are synced by ogizanagi · Pull Request #16148 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Add test to ensure translation files are synced #16148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
8000 Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>Yetkilendirme girdileri bulunamadı.</target>
<target>Kimlik bilgileri bulunamadı.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>Bir sistem hatası nedeniyle yetkilendirme isteği işleme alınamıyor.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Geçersiz girdiler.</target>
<target>Geçersiz kimlik bilgileri.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
Expand All @@ -32,7 +32,7 @@
</trans-unit>
<trans-unit id="8">
<source>Digest nonce has expired.</source>
<target>Derleme zaman aşımı gerçekleşti.</target>
<target>Derleme zaman aşımına uğradı.</target>
</trans-unit>
<trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source>
Expand All @@ -44,7 +44,7 @@
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
<target>Bilet bulunamadı.</target>
<target>Fiş bulunamadı.</target>
</trans-unit>
<trans-unit id="12">
<source>Username could not be found.</source>
Expand All @@ -56,11 +56,11 @@
</trans-unit>
<trans-unit id="14">
<source>Credentials have expired.</source>
<target>Girdiler zaman aşımına uğradı.</target>
<target>Kimlik bilgileri zaman aşımına uğradı.</target>
</trans-unit>
<trans-unit id="15">
<source>Account is disabled.</source>
<target>Hesap devre dışı bırakılmış.</target>
<target>Hesap engellenmiş.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

class SyncedTranslationsTest extends PHPUnit_Framework_TestCase
{
private $securityRootDir;
private $securityTransDir;
private $securityCoreTransDir;

public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->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;
}
}
0