From 04848a45c92f48b30479aa2c7529ad0c2802b888 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sun, 9 Jun 2013 16:10:59 +0300 Subject: [PATCH] Default action of "yii\console\controllers\MessageController" has been renamed to "generate". --- .../yii/console/controllers/MessageController.php | 8 ++++++-- .../console/controllers/MessageControllerTest.php | 18 ++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/framework/yii/console/controllers/MessageController.php b/framework/yii/console/controllers/MessageController.php index 04bb65d..21071bc 100644 --- a/framework/yii/console/controllers/MessageController.php +++ b/framework/yii/console/controllers/MessageController.php @@ -23,6 +23,10 @@ use yii\helpers\FileHelper; class MessageController extends Controller { /** + * @var string controller default action ID. + */ + public $defaultAction = 'generate'; + /** * Searches for messages to be translated in the specified * source files and compiles them into PHP arrays as message source. * @@ -58,7 +62,7 @@ class MessageController extends Controller * - sort: sort messages by key when merging, regardless of their translation * state (new, obsolete, translated.) */ - public function actionIndex($config) + public function actionGenerate($config) { if (!is_file($config)) { throw new Exception("the configuration file {$config} does not exist."); @@ -233,7 +237,7 @@ EOD; } /** - * Creates template of configuration file for [[actionIndex]]. + * Creates template of configuration file for [[actionGenerate]]. * @param string $configFile output file name. * @throws \yii\console\Exception on failure. */ diff --git a/tests/unit/framework/console/controllers/MessageControllerTest.php b/tests/unit/framework/console/controllers/MessageControllerTest.php index 396ec79..9b639d7 100644 --- a/tests/unit/framework/console/controllers/MessageControllerTest.php +++ b/tests/unit/framework/console/controllers/MessageControllerTest.php @@ -160,10 +160,8 @@ class MessageControllerTest extends TestCase public function testConfigFileNotExist() { - $this->markTestIncomplete('MessageController is incomplete'); - $this->setExpectedException('yii\\console\\Exception'); - $this->runMessageControllerAction('index', array('not_existing_file.php')); + $this->runMessageControllerAction('generate', array('not_existing_file.php')); } public function testCreateTranslation() @@ -182,7 +180,7 @@ class MessageControllerTest extends TestCase 'sourcePath' => $this->sourcePath, 'messagePath' => $this->messagePath, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $this->assertTrue(file_exists($this->messagePath . DIRECTORY_SEPARATOR . $language), 'No language dir created!'); $messageFileName = $this->messagePath . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $category . '.php'; @@ -209,7 +207,7 @@ class MessageControllerTest extends TestCase 'sourcePath' => $this->sourcePath, 'messagePath' => $this->messagePath, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $messageFileName = $this->messagePath . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $category . '.php'; @@ -218,7 +216,7 @@ class MessageControllerTest extends TestCase $messageFileContent .= '// some not generated by command content'; file_put_contents($messageFileName, $messageFileContent); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $this->assertEquals($messageFileContent, file_get_contents($messageFileName)); } @@ -249,7 +247,7 @@ class MessageControllerTest extends TestCase 'messagePath' => $this->messagePath, 'overwrite' => true, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $messages = require($this->messagePath . DIRECTORY_SEPARATOR . $messageFileName); $this->assertTrue(array_key_exists($newMessage, $messages), 'Unable to add new message!'); @@ -283,7 +281,7 @@ class MessageControllerTest extends TestCase 'overwrite' => true, 'removeOld' => false, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $messages = require($this->messagePath . DIRECTORY_SEPARATOR . $messageFileName); @@ -321,7 +319,7 @@ class MessageControllerTest extends TestCase 'messagePath' => $this->messagePath, 'overwrite' => true, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $messages = require($this->messagePath . DIRECTORY_SEPARATOR . $messageFileName); $this->assertTrue($zeroMessageContent === $messages[$zeroMessage], 'Message content "0" is lost!'); @@ -357,7 +355,7 @@ class MessageControllerTest extends TestCase 'messagePath' => $this->messagePath, 'translator' => $translators, )); - $this->runMessageControllerAction('index', array($this->configFileName)); + $this->runMessageControllerAction('generate', array($this->configFileName)); $messageFileName = $this->messagePath . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $category . '.php'; $messages = require($messageFileName);