Browse Source

Default action of "yii\console\controllers\MessageController" has been renamed to "generate".

tags/2.0.0-beta
Klimov Paul 12 years ago
parent
commit
04848a45c9
  1. 8
      framework/yii/console/controllers/MessageController.php
  2. 18
      tests/unit/framework/console/controllers/MessageControllerTest.php

8
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.
*/

18
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);

Loading…
Cancel
Save