Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
04848a45
Commit
04848a45
authored
Jun 09, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default action of "yii\console\controllers\MessageController" has been renamed to "generate".
parent
4a164f8a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
MessageController.php
framework/yii/console/controllers/MessageController.php
+6
-2
MessageControllerTest.php
...t/framework/console/controllers/MessageControllerTest.php
+8
-10
No files found.
framework/yii/console/controllers/MessageController.php
View file @
04848a45
...
@@ -23,6 +23,10 @@ use yii\helpers\FileHelper;
...
@@ -23,6 +23,10 @@ use yii\helpers\FileHelper;
class
MessageController
extends
Controller
class
MessageController
extends
Controller
{
{
/**
/**
* @var string controller default action ID.
*/
public
$defaultAction
=
'generate'
;
/**
* Searches for messages to be translated in the specified
* Searches for messages to be translated in the specified
* source files and compiles them into PHP arrays as message source.
* source files and compiles them into PHP arrays as message source.
*
*
...
@@ -58,7 +62,7 @@ class MessageController extends Controller
...
@@ -58,7 +62,7 @@ class MessageController extends Controller
* - sort: sort messages by key when merging, regardless of their translation
* - sort: sort messages by key when merging, regardless of their translation
* state (new, obsolete, translated.)
* state (new, obsolete, translated.)
*/
*/
public
function
action
Index
(
$config
)
public
function
action
Generate
(
$config
)
{
{
if
(
!
is_file
(
$config
))
{
if
(
!
is_file
(
$config
))
{
throw
new
Exception
(
"the configuration file
{
$config
}
does not exist."
);
throw
new
Exception
(
"the configuration file
{
$config
}
does not exist."
);
...
@@ -233,7 +237,7 @@ EOD;
...
@@ -233,7 +237,7 @@ EOD;
}
}
/**
/**
* Creates template of configuration file for [[action
Index
]].
* Creates template of configuration file for [[action
Generate
]].
* @param string $configFile output file name.
* @param string $configFile output file name.
* @throws \yii\console\Exception on failure.
* @throws \yii\console\Exception on failure.
*/
*/
...
...
tests/unit/framework/console/controllers/MessageControllerTest.php
View file @
04848a45
...
@@ -160,10 +160,8 @@ class MessageControllerTest extends TestCase
...
@@ -160,10 +160,8 @@ class MessageControllerTest extends TestCase
public
function
testConfigFileNotExist
()
public
function
testConfigFileNotExist
()
{
{
$this
->
markTestIncomplete
(
'MessageController is incomplete'
);
$this
->
setExpectedException
(
'yii\\console\\Exception'
);
$this
->
setExpectedException
(
'yii\\console\\Exception'
);
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
'not_existing_file.php'
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
'not_existing_file.php'
));
}
}
public
function
testCreateTranslation
()
public
function
testCreateTranslation
()
...
@@ -182,7 +180,7 @@ class MessageControllerTest extends TestCase
...
@@ -182,7 +180,7 @@ class MessageControllerTest extends TestCase
'sourcePath'
=>
$this
->
sourcePath
,
'sourcePath'
=>
$this
->
sourcePath
,
'messagePath'
=>
$this
->
messagePath
,
'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!'
);
$this
->
assertTrue
(
file_exists
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
),
'No language dir created!'
);
$messageFileName
=
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
;
$messageFileName
=
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
;
...
@@ -209,7 +207,7 @@ class MessageControllerTest extends TestCase
...
@@ -209,7 +207,7 @@ class MessageControllerTest extends TestCase
'sourcePath'
=>
$this
->
sourcePath
,
'sourcePath'
=>
$this
->
sourcePath
,
'messagePath'
=>
$this
->
messagePath
,
'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'
;
$messageFileName
=
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
;
...
@@ -218,7 +216,7 @@ class MessageControllerTest extends TestCase
...
@@ -218,7 +216,7 @@ class MessageControllerTest extends TestCase
$messageFileContent
.=
'// some not generated by command content'
;
$messageFileContent
.=
'// some not generated by command content'
;
file_put_contents
(
$messageFileName
,
$messageFileContent
);
file_put_contents
(
$messageFileName
,
$messageFileContent
);
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
$this
->
configFileName
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
$this
->
configFileName
));
$this
->
assertEquals
(
$messageFileContent
,
file_get_contents
(
$messageFileName
));
$this
->
assertEquals
(
$messageFileContent
,
file_get_contents
(
$messageFileName
));
}
}
...
@@ -249,7 +247,7 @@ class MessageControllerTest extends TestCase
...
@@ -249,7 +247,7 @@ class MessageControllerTest extends TestCase
'messagePath'
=>
$this
->
messagePath
,
'messagePath'
=>
$this
->
messagePath
,
'overwrite'
=>
true
,
'overwrite'
=>
true
,
));
));
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
$this
->
configFileName
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
$this
->
configFileName
));
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
$this
->
assertTrue
(
array_key_exists
(
$newMessage
,
$messages
),
'Unable to add new message!'
);
$this
->
assertTrue
(
array_key_exists
(
$newMessage
,
$messages
),
'Unable to add new message!'
);
...
@@ -283,7 +281,7 @@ class MessageControllerTest extends TestCase
...
@@ -283,7 +281,7 @@ class MessageControllerTest extends TestCase
'overwrite'
=>
true
,
'overwrite'
=>
true
,
'removeOld'
=>
false
,
'removeOld'
=>
false
,
));
));
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
$this
->
configFileName
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
$this
->
configFileName
));
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
...
@@ -321,7 +319,7 @@ class MessageControllerTest extends TestCase
...
@@ -321,7 +319,7 @@ class MessageControllerTest extends TestCase
'messagePath'
=>
$this
->
messagePath
,
'messagePath'
=>
$this
->
messagePath
,
'overwrite'
=>
true
,
'overwrite'
=>
true
,
));
));
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
$this
->
configFileName
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
$this
->
configFileName
));
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
$messages
=
require
(
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$messageFileName
);
$this
->
assertTrue
(
$zeroMessageContent
===
$messages
[
$zeroMessage
],
'Message content "0" is lost!'
);
$this
->
assertTrue
(
$zeroMessageContent
===
$messages
[
$zeroMessage
],
'Message content "0" is lost!'
);
...
@@ -357,7 +355,7 @@ class MessageControllerTest extends TestCase
...
@@ -357,7 +355,7 @@ class MessageControllerTest extends TestCase
'messagePath'
=>
$this
->
messagePath
,
'messagePath'
=>
$this
->
messagePath
,
'translator'
=>
$translators
,
'translator'
=>
$translators
,
));
));
$this
->
runMessageControllerAction
(
'
index
'
,
array
(
$this
->
configFileName
));
$this
->
runMessageControllerAction
(
'
generate
'
,
array
(
$this
->
configFileName
));
$messageFileName
=
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
;
$messageFileName
=
$this
->
messagePath
.
DIRECTORY_SEPARATOR
.
$language
.
DIRECTORY_SEPARATOR
.
$category
.
'.php'
;
$messages
=
require
(
$messageFileName
);
$messages
=
require
(
$messageFileName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment