Fixes #11502: Fixed yii\console\controllers\MessageController to properly populate missing languages in case of extraction with "db" format

This commit is contained in:
Bizley
2017-01-26 10:46:23 +01:00
committed by Alexander Makarov
parent 68ee789fdc
commit 1749c46c5d
4 changed files with 287 additions and 54 deletions

View File

@@ -402,6 +402,32 @@ abstract class BaseMessageControllerTest extends TestCase
$this->assertArrayHasKey($mainMessage, $messages, "\"$mainMessage\" is missing in translation file. Command output:\n\n" . $out);
$this->assertArrayHasKey($nestedMessage, $messages, "\"$nestedMessage\" is missing in translation file. Command output:\n\n" . $out);
}
/**
* @depends testCreateTranslation
*
* @see https://github.com/yiisoft/yii2/issues/11502
*/
public function testMissingLanguage()
{
$category = 'multiLangCategory';
$mainMessage = 'multiLangMessage';
$sourceFileContent = "Yii::t('{$category}', '{$mainMessage}');";
$this->createSourceFile($sourceFileContent);
$this->saveConfigFile($this->getConfig());
$out = $this->runMessageControllerAction('extract', [$this->configFileName]);
$secondLanguage = 'pl';
$this->saveConfigFile($this->getConfig(['languages' => [$this->language, $secondLanguage]]));
$out .= $this->runMessageControllerAction('extract', [$this->configFileName]);
$firstLanguage = $this->language;
$this->language = $secondLanguage;
$messages = $this->loadMessages($category);
$this->language = $firstLanguage;
$this->assertArrayHasKey($mainMessage, $messages, "\"$mainMessage\" for language \"$secondLanguage\" is missing in translation file. Command output:\n\n" . $out);
}
}
class MessageControllerMock extends MessageController