Added test for compare localizations

This commit is contained in:
Dmitry Khomutov 2017-01-10 20:41:31 +07:00
parent 1139d28ddd
commit 8c355bba8c
4 changed files with 60 additions and 10 deletions

View file

@ -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',
);
];

View file

@ -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',
);
];

View file

@ -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('<time datetime="ISODATE" data-format="lll">RFCDATE</time>', 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);
}
}*/
}

View file

@ -0,0 +1,24 @@
<?php
namespace Tests\PHPCensor;
class LocalizationTestCase extends \PHPUnit_Framework_TestCase
{
/**
* Returns a string representation of the test case.
*
* @return string
*/
public function toString()
{
$class = new \ReflectionClass($this);
$buffer = sprintf(
'%s::%s',
$class->name,
$this->getName(false)
);
return $buffer . $this->getDataSetAsString(false);
}
}