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
31819641
Commit
31819641
authored
Dec 18, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored TestCase.
parent
157b1ffd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
TestCase.php
extensions/yii/codeception/TestCase.php
+19
-2
No files found.
extensions/yii/codeception/TestCase.php
View file @
31819641
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
yii\codeception
;
namespace
yii\codeception
;
use
Yii
;
use
Yii
;
use
yii\base\InvalidConfigException
;
/**
/**
* TestCase is the base class for all codeception unit tests
* TestCase is the base class for all codeception unit tests
...
@@ -13,7 +14,8 @@ use Yii;
...
@@ -13,7 +14,8 @@ use Yii;
class
TestCase
extends
\PHPUnit_Framework_TestCase
class
TestCase
extends
\PHPUnit_Framework_TestCase
{
{
/**
/**
* @var array the application configuration that will be used for creating an application instance for each test.
* @var array|string the application configuration that will be used for creating an application instance for each test.
* You can use a string to represent the file path or path alias of a configuration file.
*/
*/
public
static
$appConfig
=
[];
public
static
$appConfig
=
[];
/**
/**
...
@@ -21,6 +23,14 @@ class TestCase extends \PHPUnit_Framework_TestCase
...
@@ -21,6 +23,14 @@ class TestCase extends \PHPUnit_Framework_TestCase
*/
*/
public
static
$appClass
=
'yii\web\Application'
;
public
static
$appClass
=
'yii\web\Application'
;
/**
* @inheritdoc
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
}
/**
/**
* @inheritdoc
* @inheritdoc
...
@@ -39,7 +49,14 @@ class TestCase extends \PHPUnit_Framework_TestCase
...
@@ -39,7 +49,14 @@ class TestCase extends \PHPUnit_Framework_TestCase
*/
*/
protected
function
mockApplication
(
$config
=
null
)
protected
function
mockApplication
(
$config
=
null
)
{
{
return
new
static
::
$appClass
(
$config
===
null
?
static
::
$appConfig
:
$config
);
$config
=
$config
===
null
?
static
::
$appConfig
:
$config
;
if
(
is_string
(
$config
))
{
$config
=
Yii
::
getAlias
(
$config
);
}
if
(
!
is_array
(
$config
))
{
throw
new
InvalidConfigException
(
'Please provide a configuration for creating application.'
);
}
return
new
static
::
$appClass
(
$config
);
}
}
/**
/**
...
...
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