diff --git a/src/PHPCensor/Languages/lang.pt-br.php b/src/PHPCensor/Languages/lang.pt-br.php index 4b27d313..33551776 100644 --- a/src/PHPCensor/Languages/lang.pt-br.php +++ b/src/PHPCensor/Languages/lang.pt-br.php @@ -7,7 +7,7 @@ * @link https://www.phptesting.org/ */ -$strings = array( +return [ 'language_name' => 'Português Brasil', 'language' => 'Idioma', @@ -419,7 +419,6 @@ PHP Censor', 'could_not_process_report' => 'Could not process the report generated by this tool.', 'shell_not_enabled' => 'The shell plugin is not enabled. Please enable it via config.yml.', - // Error Levels: 'critical' => 'Critical', 'high' => 'High', @@ -434,4 +433,4 @@ PHP Censor', 'php_docblock_checker' => 'PHP Docblock Checker', 'behat' => 'Behat', 'technical_debt' => 'Technical Debt', -); +]; diff --git a/src/PHPCensor/Languages/lang.zh.php b/src/PHPCensor/Languages/lang.zh.php index 9387097e..c25ff633 100644 --- a/src/PHPCensor/Languages/lang.zh.php +++ b/src/PHPCensor/Languages/lang.zh.php @@ -7,7 +7,7 @@ * @link https://www.phptesting.org/ */ -$strings = array( +return [ 'language_name' => '简体中文', 'language' => '语言选择', @@ -412,7 +412,6 @@ PHP Censor', 'could_not_process_report' => 'Could not process the report generated by this tool.', 'shell_not_enabled' => 'The shell plugin is not enabled. Please enable it via config.yml.', - // Error Levels: 'critical' => 'Critical', 'high' => 'High', @@ -425,7 +424,4 @@ PHP Censor', 'php_unit' => 'PHP Unit', 'php_cpd' => 'PHP Copy/Paste Detector', 'php_docblock_checker' => 'PHP Docblock Checker', - 'behat' => 'Behat', - 'technical_debt' => 'Technical Debt', - -); +]; diff --git a/tests/PHPCensor/Helper/LangTest.php b/tests/PHPCensor/Helper/LangTest.php index ed0b7b28..17640ce3 100644 --- a/tests/PHPCensor/Helper/LangTest.php +++ b/tests/PHPCensor/Helper/LangTest.php @@ -12,8 +12,9 @@ namespace Tests\PHPCensor\Helper; use DateTime; use PHPCensor\Helper\Lang; +use Tests\PHPCensor\LocalizationTestCase; -class LangTest extends \PHPUnit_Framework_TestCase +class LangTest extends LocalizationTestCase { public function testLang_UsePassedParameters() { @@ -32,4 +33,34 @@ class LangTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', Lang::formatDateTime($dateTime->reveal())); } + + /** + * @return array + */ + public function localizationsProvider() + { + $directory = SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR; + $languages = []; + foreach(glob($directory . '*') as $file) { + $language = include($file); + $languages[$file] = [ + $language + ]; + } + + return $languages; + } + + /** + * @dataProvider localizationsProvider + */ + /*public function testLocalizations(array $strings) + { + $directory = SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR; + $en = include($directory . 'lang.en.php'); + + foreach ($en as $enIndex => $enString) { + $this->assertArrayHasKey($enIndex, $strings); + } + }*/ } diff --git a/tests/PHPCensor/LocalizationTestCase.php b/tests/PHPCensor/LocalizationTestCase.php new file mode 100644 index 00000000..25bb0443 --- /dev/null +++ b/tests/PHPCensor/LocalizationTestCase.php @@ -0,0 +1,24 @@ +name, + $this->getName(false) + ); + + return $buffer . $this->getDataSetAsString(false); + } +}