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
f4cb1e4a
Commit
f4cb1e4a
authored
May 16, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit test for "console\controllers\AssetController" has been created.
parent
236230e8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
AssetControllerTest.php
...nit/framework/console/controllers/AssetControllerTest.php
+90
-0
No files found.
tests/unit/framework/console/controllers/AssetControllerTest.php
0 → 100644
View file @
f4cb1e4a
<?php
use
yiiunit\TestCase
;
use
yii\console\controllers\AssetController
;
/**
* Unit test for [[yii\console\controllers\AssetController]].
* @see AssetController
*/
class
AssetControllerTest
extends
TestCase
{
/**
* @var string path for the test files.
*/
protected
$testFilePath
=
''
;
public
function
setUp
()
{
$this
->
testFilePath
=
Yii
::
getAlias
(
'@yiiunit/runtime'
)
.
DIRECTORY_SEPARATOR
.
get_class
(
$this
);
$this
->
createDir
(
$this
->
testFilePath
);
}
public
function
tearDown
()
{
$this
->
removeDir
(
$this
->
testFilePath
);
}
/**
* Creates directory.
* @param $dirName directory full name.
*/
protected
function
createDir
(
$dirName
)
{
if
(
!
file_exists
(
$dirName
))
{
mkdir
(
$dirName
,
0777
,
true
);
}
}
/**
* Removes directory.
* @param $dirName directory full name
*/
protected
function
removeDir
(
$dirName
)
{
if
(
!
empty
(
$dirName
)
&&
file_exists
(
$dirName
))
{
exec
(
"rm -rf
{
$dirName
}
"
);
}
}
/**
* Creates test asset controller instance.
* @return AssetController
*/
protected
function
createAssetController
()
{
$module
=
$this
->
getMock
(
'yii\\base\\Module'
,
array
(
'fake'
),
array
(
'console'
));
$assetController
=
new
AssetController
(
'asset'
,
$module
);
$assetController
->
jsCompressor
=
'cp {from} {to}'
;
$assetController
->
cssCompressor
=
'cp {from} {to}'
;
return
$assetController
;
}
/**
* Emulates running of the asset controller action.
* @param string $actionId id of action to be run.
* @param array $args action arguments.
* @return string command output.
*/
protected
function
runAssetControllerAction
(
$actionId
,
array
$args
=
array
())
{
$controller
=
$this
->
createAssetController
();
ob_start
();
ob_implicit_flush
(
false
);
$params
=
array
(
\yii\console\Request
::
ANONYMOUS_PARAMS
=>
$args
);
$controller
->
run
(
$actionId
,
$params
);
return
ob_get_clean
();
}
// Tests :
public
function
testActionTemplate
()
{
$configFileName
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'config.php'
;
$this
->
runAssetControllerAction
(
'template'
,
array
(
$configFileName
));
$this
->
assertTrue
(
file_exists
(
$configFileName
),
'Unable to create config file template!'
);
}
}
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