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
5e0f6604
Commit
5e0f6604
authored
May 09, 2013
by
Benjamin Wöster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mod: don't create app in bootstrap script, unit tests do it themselves
add: option to destroy app after each test to find unit tests that fail to require an app
parent
d4b30e26
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
TestCase.php
tests/unit/TestCase.php
+20
-0
bootstrap.php
tests/unit/bootstrap.php
+1
-2
No files found.
tests/unit/TestCase.php
View file @
5e0f6604
...
...
@@ -6,6 +6,21 @@ class TestCase extends \yii\test\TestCase
{
public
static
$params
;
protected
function
setUp
()
{
parent
::
setUp
();
}
protected
function
tearDown
()
{
parent
::
tearDown
();
// If defined and set to true, destroy the app after each test.
// This will cause tests to fail, that rely on an existing app, but don't
// call requireApp() in their setUp().
if
(
defined
(
'YII_DESTROY_APP_ON_TEARDOWN'
)
&&
YII_DESTROY_APP_ON_TEARDOWN
===
true
)
{
$this
->
destroyApp
();
}
}
public
function
getParam
(
$name
)
{
if
(
self
::
$params
===
null
)
{
...
...
@@ -32,4 +47,9 @@ class TestCase extends \yii\test\TestCase
$usedConfig
=
$newConfig
;
}
}
protected
function
destroyApp
()
{
\yii
::
$app
=
null
;
}
}
tests/unit/bootstrap.php
View file @
5e0f6604
...
...
@@ -2,6 +2,7 @@
define
(
'YII_ENABLE_ERROR_HANDLER'
,
false
);
define
(
'YII_DEBUG'
,
true
);
define
(
'YII_DESTROY_APP_ON_TEARDOWN'
,
false
);
$_SERVER
[
'SCRIPT_NAME'
]
=
'/'
.
__DIR__
;
$_SERVER
[
'SCRIPT_FILENAME'
]
=
__FILE__
;
...
...
@@ -9,6 +10,4 @@ require_once(__DIR__ . '/../../yii/Yii.php');
Yii
::
setAlias
(
'@yiiunit'
,
__DIR__
);
new
\yii\web\Application
(
array
(
'id'
=>
'testapp'
,
'basePath'
=>
__DIR__
));
require_once
(
__DIR__
.
'/TestCase.php'
);
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