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
f21c2c29
Commit
f21c2c29
authored
Sep 05, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test breaks.
parent
a27b6e92
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
14 deletions
+26
-14
TestCase.php
tests/unit/TestCase.php
+19
-12
.gitignore
tests/unit/assets/.gitignore
+3
-0
bootstrap.php
tests/unit/bootstrap.php
+2
-0
ViewRendererTest.php
tests/unit/extensions/smarty/ViewRendererTest.php
+1
-1
ViewRendererTest.php
tests/unit/extensions/twig/ViewRendererTest.php
+1
-1
No files found.
tests/unit/TestCase.php
View file @
f21c2c29
...
@@ -23,8 +23,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
...
@@ -23,8 +23,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
/**
/**
* Returns a test configuration param from /data/config.php
* Returns a test configuration param from /data/config.php
* @param string $name
params name
* @param string $name params name
* @param mixed
$default default value to use when param is not set.
* @param mixed $default default value to use when param is not set.
* @return mixed the value of the configuration param
* @return mixed the value of the configuration param
*/
*/
public
static
function
getParam
(
$name
,
$default
=
null
)
public
static
function
getParam
(
$name
,
$default
=
null
)
...
@@ -39,34 +39,41 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
...
@@ -39,34 +39,41 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
/**
/**
* Populates Yii::$app with a new application
* Populates Yii::$app with a new application
* The application will be destroyed on tearDown() automatically.
* The application will be destroyed on tearDown() automatically.
* @param array
$config
The application configuration, if needed
* @param array
$config
The application configuration, if needed
* @param string $appClass name of the application class to create
* @param string $appClass name of the application class to create
*/
*/
protected
function
mockApplication
(
$config
=
[],
$appClass
=
'\yii\console\Application'
)
protected
function
mockApplication
(
$config
=
[],
$appClass
=
'\yii\console\Application'
)
{
{
static
$defaultConfig
=
[
new
$appClass
(
ArrayHelper
::
merge
(
[
'id'
=>
'testapp'
,
'id'
=>
'testapp'
,
'basePath'
=>
__DIR__
,
'basePath'
=>
__DIR__
,
];
'vendorPath'
=>
$this
->
getVendorPath
(),
$defaultConfig
[
'vendorPath'
]
=
dirname
(
dirname
(
__DIR__
))
.
'/vendor'
;
],
$config
));
new
$appClass
(
ArrayHelper
::
merge
(
$defaultConfig
,
$config
));
}
}
protected
function
mockWebApplication
(
$config
=
[],
$appClass
=
'\yii\web\Application'
)
protected
function
mockWebApplication
(
$config
=
[],
$appClass
=
'\yii\web\Application'
)
{
{
static
$defaultConfig
=
[
new
$appClass
(
ArrayHelper
::
merge
(
[
'id'
=>
'testapp'
,
'id'
=>
'testapp'
,
'basePath'
=>
__DIR__
,
'basePath'
=>
__DIR__
,
'vendorPath'
=>
$this
->
getVendorPath
(),
'components'
=>
[
'components'
=>
[
'request'
=>
[
'request'
=>
[
'cookieValidationKey'
=>
'wefJDF8sfdsfSDefwqdxj9oq'
,
'cookieValidationKey'
=>
'wefJDF8sfdsfSDefwqdxj9oq'
,
'scriptFile'
=>
__DIR__
.
'/index.php'
,
'scriptUrl'
=>
'/index.php'
,
],
],
]
]
];
]
,
$config
))
;
$defaultConfig
[
'vendorPath'
]
=
dirname
(
dirname
(
__DIR__
))
.
'/vendor'
;
}
new
$appClass
(
ArrayHelper
::
merge
(
$defaultConfig
,
$config
));
protected
function
getVendorPath
()
{
$vendor
=
dirname
(
dirname
(
__DIR__
))
.
'/vendor'
;
if
(
!
is_dir
(
$vendor
))
{
$vendor
=
dirname
(
dirname
(
dirname
(
dirname
(
__DIR__
))));
}
return
$vendor
;
}
}
/**
/**
...
...
tests/unit/assets/.gitignore
0 → 100644
View file @
f21c2c29
*
!.gitignore
!/coveralls/.gitkeep
tests/unit/bootstrap.php
View file @
f21c2c29
...
@@ -12,6 +12,8 @@ $_SERVER['SCRIPT_FILENAME'] = __FILE__;
...
@@ -12,6 +12,8 @@ $_SERVER['SCRIPT_FILENAME'] = __FILE__;
$composerAutoload
=
__DIR__
.
'/../../vendor/autoload.php'
;
$composerAutoload
=
__DIR__
.
'/../../vendor/autoload.php'
;
if
(
is_file
(
$composerAutoload
))
{
if
(
is_file
(
$composerAutoload
))
{
require_once
(
$composerAutoload
);
require_once
(
$composerAutoload
);
}
else
{
require_once
(
__DIR__
.
'/../../../../autoload.php'
);
}
}
require_once
(
__DIR__
.
'/../../framework/Yii.php'
);
require_once
(
__DIR__
.
'/../../framework/Yii.php'
);
...
...
tests/unit/extensions/smarty/ViewRendererTest.php
View file @
f21c2c29
...
@@ -22,7 +22,7 @@ class ViewRendererTest extends TestCase
...
@@ -22,7 +22,7 @@ class ViewRendererTest extends TestCase
protected
function
setUp
()
protected
function
setUp
()
{
{
parent
::
setUp
();
parent
::
setUp
();
$this
->
mockApplication
();
$this
->
mock
Web
Application
();
}
}
protected
function
tearDown
()
protected
function
tearDown
()
...
...
tests/unit/extensions/twig/ViewRendererTest.php
View file @
f21c2c29
...
@@ -22,7 +22,7 @@ class ViewRendererTest extends DatabaseTestCase
...
@@ -22,7 +22,7 @@ class ViewRendererTest extends DatabaseTestCase
protected
function
setUp
()
protected
function
setUp
()
{
{
parent
::
setUp
();
parent
::
setUp
();
$this
->
mockApplication
();
$this
->
mock
Web
Application
();
}
}
protected
function
tearDown
()
protected
function
tearDown
()
...
...
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