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
4a164f8a
Commit
4a164f8a
authored
Jun 09, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Action "template" has been added to "yii\console\controllers\MessageController".
parent
3c9b1578
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
5 deletions
+50
-5
MessageController.php
framework/yii/console/controllers/MessageController.php
+41
-1
MessageControllerTest.php
...t/framework/console/controllers/MessageControllerTest.php
+9
-4
No files found.
framework/yii/console/controllers/MessageController.php
View file @
4a164f8a
...
...
@@ -224,11 +224,51 @@ class MessageController extends Controller
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE
,
this file must be saved in UTF-8 encoding.
* NOTE
:
this file must be saved in UTF-8 encoding.
*/
return $array;
EOD;
file_put_contents
(
$fileName
,
$content
);
}
/**
* Creates template of configuration file for [[actionIndex]].
* @param string $configFile output file name.
* @throws \yii\console\Exception on failure.
*/
public
function
actionTemplate
(
$configFile
)
{
$template
=
<<<EOD
<?php
/**
* Configuration file for the "yii {$this->id}" console command.
*/
return array(
'sourcePath' => __DIR__,
'messagePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages',
'languages' => array(),
'fileTypes' => array('php'),
'overwrite' => true,
'exclude' => array(
'.svn',
'.gitignore',
'.gitkeep',
'.hgignore',
'.hgkeep',
'/messages',
),
);
EOD;
if
(
file_exists
(
$configFile
))
{
if
(
!
$this
->
confirm
(
"File '
{
$configFile
}
' already exists. Do you wish to overwrite it?"
))
{
return
;
}
}
if
(
!
file_put_contents
(
$configFile
,
$template
))
{
throw
new
Exception
(
"Unable to write template file '
{
$configFile
}
'."
);
}
else
{
echo
"Configuration file template created at '
{
$configFile
}
'.
\n\n
"
;
}
}
}
tests/unit/framework/console/controllers/MessageControllerTest.php
View file @
4a164f8a
...
...
@@ -151,20 +151,25 @@ class MessageControllerTest extends TestCase
// Tests:
public
function
test
EmptyArgs
()
public
function
test
ActionTemplate
()
{
$this
->
setExpectedException
(
'CException'
,
'usageError'
);
$this
->
runMessageControllerAction
(
'index'
,
array
());
$configFileName
=
$this
->
configFileName
;
$this
->
runMessageControllerAction
(
'template'
,
array
(
$configFileName
));
$this
->
assertTrue
(
file_exists
(
$configFileName
),
'Unable to create config file template!'
);
}
public
function
testConfigFileNotExist
()
{
$this
->
setExpectedException
(
'CException'
,
'usageError'
);
$this
->
markTestIncomplete
(
'MessageController is incomplete'
);
$this
->
setExpectedException
(
'yii\\console\\Exception'
);
$this
->
runMessageControllerAction
(
'index'
,
array
(
'not_existing_file.php'
));
}
public
function
testCreateTranslation
()
{
$this
->
markTestIncomplete
(
'MessageController is incomplete'
);
$language
=
'en'
;
$category
=
'test_category'
;
...
...
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