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
d4b30e26
Commit
d4b30e26
authored
May 09, 2013
by
Benjamin Wöster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow unit tests to requireApp() on setUp()
parent
8332e8c6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
10 deletions
+30
-10
TestCase.php
tests/unit/TestCase.php
+19
-0
CacheTest.php
tests/unit/framework/caching/CacheTest.php
+6
-0
DbCacheTest.php
tests/unit/framework/caching/DbCacheTest.php
+2
-0
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+3
-10
No files found.
tests/unit/TestCase.php
View file @
d4b30e26
...
@@ -13,4 +13,23 @@ class TestCase extends \yii\test\TestCase
...
@@ -13,4 +13,23 @@ class TestCase extends \yii\test\TestCase
}
}
return
isset
(
self
::
$params
[
$name
])
?
self
::
$params
[
$name
]
:
null
;
return
isset
(
self
::
$params
[
$name
])
?
self
::
$params
[
$name
]
:
null
;
}
}
protected
function
requireApp
(
$requiredConfig
=
array
())
{
static
$usedConfig
=
array
();
static
$defaultConfig
=
array
(
'id'
=>
'testapp'
,
'basePath'
=>
__DIR__
,
);
$newConfig
=
array_merge
(
$defaultConfig
,
$requiredConfig
);
if
(
!
(
\yii
::
$app
instanceof
\yii\web\Application
))
{
new
\yii\web\Application
(
$newConfig
);
$usedConfig
=
$newConfig
;
}
elseif
(
$newConfig
!==
$usedConfig
)
{
new
\yii\web\Application
(
$newConfig
);
$usedConfig
=
$newConfig
;
}
}
}
}
tests/unit/framework/caching/CacheTest.php
View file @
d4b30e26
...
@@ -13,6 +13,12 @@ abstract class CacheTest extends TestCase
...
@@ -13,6 +13,12 @@ abstract class CacheTest extends TestCase
*/
*/
abstract
protected
function
getCacheInstance
();
abstract
protected
function
getCacheInstance
();
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
requireApp
();
}
public
function
testSet
()
public
function
testSet
()
{
{
$cache
=
$this
->
getCacheInstance
();
$cache
=
$this
->
getCacheInstance
();
...
...
tests/unit/framework/caching/DbCacheTest.php
View file @
d4b30e26
...
@@ -17,6 +17,8 @@ class DbCacheTest extends CacheTest
...
@@ -17,6 +17,8 @@ class DbCacheTest extends CacheTest
$this
->
markTestSkipped
(
'pdo and pdo_mysql extensions are required.'
);
$this
->
markTestSkipped
(
'pdo and pdo_mysql extensions are required.'
);
}
}
parent
::
setUp
();
$this
->
getConnection
()
->
createCommand
(
"
$this
->
getConnection
()
->
createCommand
(
"
CREATE TABLE IF NOT EXISTS tbl_cache (
CREATE TABLE IF NOT EXISTS tbl_cache (
id char(128) NOT NULL,
id char(128) NOT NULL,
...
...
tests/unit/framework/helpers/HtmlTest.php
View file @
d4b30e26
...
@@ -4,15 +4,13 @@ namespace yiiunit\framework\helpers;
...
@@ -4,15 +4,13 @@ namespace yiiunit\framework\helpers;
use
Yii
;
use
Yii
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii
\web\Application
;
use
yii
unit\TestCase
;
class
HtmlTest
extends
\yii\test\
TestCase
class
HtmlTest
extends
TestCase
{
{
public
function
setUp
()
public
function
setUp
()
{
{
new
Application
(
array
(
$this
->
requireApp
(
array
(
'id'
=>
'test'
,
'basePath'
=>
'@yiiunit/runtime'
,
'components'
=>
array
(
'components'
=>
array
(
'request'
=>
array
(
'request'
=>
array
(
'class'
=>
'yii\web\Request'
,
'class'
=>
'yii\web\Request'
,
...
@@ -30,11 +28,6 @@ class HtmlTest extends \yii\test\TestCase
...
@@ -30,11 +28,6 @@ class HtmlTest extends \yii\test\TestCase
$this
->
assertEquals
(
$expected
,
$actual
);
$this
->
assertEquals
(
$expected
,
$actual
);
}
}
public
function
tearDown
()
{
Yii
::
$app
=
null
;
}
public
function
testEncode
()
public
function
testEncode
()
{
{
$this
->
assertEquals
(
"a<>&"'"
,
Html
::
encode
(
"a<>&
\"
'"
));
$this
->
assertEquals
(
"a<>&"'"
,
Html
::
encode
(
"a<>&
\"
'"
));
...
...
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