diff --git a/tests/php-unit-tests/integration-tests/CompiledDictionariesConsistencyTest.php b/tests/php-unit-tests/integration-tests/CompiledDictionariesConsistencyTest.php new file mode 100644 index 0000000000..bc79464216 --- /dev/null +++ b/tests/php-unit-tests/integration-tests/CompiledDictionariesConsistencyTest.php @@ -0,0 +1,74 @@ + [], + 'UI:CSVReport-Value-ChangeIssue' => ['arg1'], + 'UI:CSVReport-Value-NoMatch' => ['arg1'], + 'UI:CSVReport-Value-NoMatch-PossibleValues' => ['arg1', 'arg2'], + 'UI:CSVReport-Value-NoMatch-NoObject' => ['arg1'], + 'UI:CSVReport-Value-NoMatch-NoObject-ForCurrentUser' => ['arg1'], + 'UI:CSVReport-Value-NoMatch-SomeObjectNotVisibleForCurrentUser' => ['arg1'], + ]; + + $sCompiledLanguagesFilePath = APPROOT . 'env-' . \utils::GetCurrentEnvironment() . '/dictionaries/languages.php'; + $this->assertFileExists($sCompiledLanguagesFilePath, 'We must have an existing compiled language.php file in the current env !'); + require_once($sCompiledLanguagesFilePath); + $this->assertNotEmpty(Dict::GetLanguages(), 'the languages.php file exists but didn\'t load any language'); + + foreach (glob(APPROOT . 'env-' . \utils::GetCurrentEnvironment() . '/dictionaries/*.dict.php') as $sDictFile) { + if (preg_match('/.*\\/(.*).dict.php/', $sDictFile, $aMatches)) { + $sLangCode = $aMatches[1]; + $sLanguageCode = strtoupper(str_replace('-', ' ', $sLangCode)); + Dict::SetUserLanguage($sLanguageCode); + + foreach ($aLabelsToTest as $sLabelKey => $aLabelArgs) { + echo "Testing $sDictFile, label $sLabelKey with " . \var_export($aLabelArgs, true) . "\n"; + try { + $sLabelValue = Dict::Format($sLabelKey, ...$aLabelArgs); + //$this->debug($sLabelValue); + } catch (\ValueError $e) { + $aFailedLabels[] = $sLabelKey; + + $this->debug([ + 'exception' => $e->getMessage(), + 'trace' => $e->getTraceAsString(), + 'label_name' => $sLabelKey, + 'label_args' => $aLabelArgs, + ]); + } + } + $this->assertEquals([], $aFailedLabels, "$sDictFile : test fail for lang $sLangCode and labels (" . implode(", ", $aFailedLabels) . ')'); + } + } + } +} diff --git a/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php b/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php index 38fe83f2fe..55432aecab 100644 --- a/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php +++ b/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php @@ -16,9 +16,9 @@ namespace Combodo\iTop\Test\UnitTest\Integration; use Combodo\iTop\Test\UnitTest\ItopTestCase; -use Dict; /** + * For tests on compiled dict files, see {@see CompiledDictionariesConsistencyTest} * @group beforeSetup */ class DictionariesConsistencyTest extends ItopTestCase @@ -152,67 +152,4 @@ class DictionariesConsistencyTest extends ItopTestCase $sMessage = "File `{$sDictFile}` syntax didn't matched expectations\nparsing results=".var_export($output, true); self::assertEquals($bIsSyntaxValid, $bDictFileSyntaxOk, $sMessage); } - - /** - * @dataProvider ImportCsvMessageStillOkProvider - * make sure N°5305 dictionary changes are still here and UI remains unbroken for any lang - */ - public function testImportCsvMessageStillOk($sLangCode, $sDictFile) - { - $aFailedLabels = []; - $aLabelsToTest = [ - 'UI:CSVReport-Value-SetIssue' => [], - 'UI:CSVReport-Value-ChangeIssue' => [ 'arg1' ], - 'UI:CSVReport-Value-NoMatch' => [ 'arg1' ], - 'UI:CSVReport-Value-NoMatch-PossibleValues' => [ 'arg1', 'arg2' ], - 'UI:CSVReport-Value-NoMatch-NoObject' => [ 'arg1' ], - 'UI:CSVReport-Value-NoMatch-NoObject-ForCurrentUser' => [ 'arg1' ], - 'UI:CSVReport-Value-NoMatch-SomeObjectNotVisibleForCurrentUser' => [ 'arg1' ], - ]; - - $sLanguageCode = strtoupper(str_replace('-', ' ', $sLangCode)); - require_once(APPROOT.'env-'.\utils::GetCurrentEnvironment().'/dictionaries/languages.php'); - Dict::SetUserLanguage($sLanguageCode); - foreach ($aLabelsToTest as $sLabelKey => $aLabelArgs){ - try{ - $sLabelValue = Dict::Format($sLabelKey, ...$aLabelArgs); - //$this->debug($sLabelValue); - } catch (\ValueError $e){ - $aFailedLabels[] = $sLabelKey; - - $this->debug([ - 'exception' => $e->getMessage(), - 'trace' => $e->getTraceAsString(), - 'label_name' => $sLabelKey, - 'label_args' =>$aLabelArgs, - ]); - } - } - $this->assertEquals([], $aFailedLabels, "test fail for lang $sLangCode and labels (" . implode(", ", $aFailedLabels) . ')'); - } - - public function ImportCsvMessageStillOkProvider(){ - return $this->GetDictFiles(); - } - - /** - * return a map linked to *.dict.php files that are generated after setup - * each entry key is lang code (example 'en') - * each value is an array with lang code (again) and dict file path - * @return array - */ - private function GetDictFiles() : array { - $aDictFiles = []; - - foreach (glob(APPROOT.'env-'.\utils::GetCurrentEnvironment().'/dictionaries/*.dict.php') as $sDictFile){ - if (preg_match('/.*\\/(.*).dict.php/', $sDictFile, $aMatches)){ - $sLangCode = $aMatches[1]; - $aDictFiles[$sLangCode] = [ - 'lang' => $sLangCode, - 'file' => $sDictFile - ]; - } - } - return $aDictFiles; - } } diff --git a/tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php b/tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php index 0b0aeac6df..7b96fb1b35 100644 --- a/tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php +++ b/tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php @@ -22,6 +22,7 @@ use utils; /** * @package Combodo\iTop\Test\UnitTest\Setup + * @group beforeSetup */ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase { /** diff --git a/tests/php-unit-tests/integration-tests/iTopModulesXmlVersionChecklistTest.php b/tests/php-unit-tests/integration-tests/iTopModulesXmlVersionChecklistTest.php index 646c17bcea..b69ab6cca6 100644 --- a/tests/php-unit-tests/integration-tests/iTopModulesXmlVersionChecklistTest.php +++ b/tests/php-unit-tests/integration-tests/iTopModulesXmlVersionChecklistTest.php @@ -24,6 +24,7 @@ use iTopDesignFormat; * @covers iTopDesignFormat * * @package Combodo\iTop\Test\UnitTest\Setup + * @group beforeSetup */ class iTopModulesXmlVersionIntegrationTest extends ItopTestCase { diff --git a/tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php b/tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php index ad30a6ccf7..182bf41e7d 100644 --- a/tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php +++ b/tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php @@ -20,6 +20,7 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase; /** * @package Combodo\iTop\Test\UnitTest\Setup + * @group beforeSetup */ class iTopXmlVersionIntegrationTest extends ItopTestCase {