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
cb8f5d70
Commit
cb8f5d70
authored
May 11, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup tests
parent
e0ad7125
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
71 additions
and
35 deletions
+71
-35
DatabaseTestCase.php
tests/unit/DatabaseTestCase.php
+1
-0
MysqlTestCase.php
tests/unit/MysqlTestCase.php
+1
-0
TestCase.php
tests/unit/TestCase.php
+28
-11
YiiBaseTest.php
tests/unit/framework/YiiBaseTest.php
+4
-2
ComponentTest.php
tests/unit/framework/base/ComponentTest.php
+4
-2
DictionaryTest.php
tests/unit/framework/base/DictionaryTest.php
+4
-2
ObjectTest.php
tests/unit/framework/base/ObjectTest.php
+4
-2
VectorTest.php
tests/unit/framework/base/VectorTest.php
+4
-2
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+1
-1
SqliteActiveRecordTest.php
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
+1
-1
SqliteCommandTest.php
tests/unit/framework/db/sqlite/SqliteCommandTest.php
+2
-2
SqliteConnectionTest.php
tests/unit/framework/db/sqlite/SqliteConnectionTest.php
+5
-5
SqliteQueryTest.php
tests/unit/framework/db/sqlite/SqliteQueryTest.php
+1
-1
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+2
-1
VarDumperTest.php
tests/unit/framework/helpers/VarDumperTest.php
+3
-0
PhpManagerTest.php
tests/unit/framework/rbac/PhpManagerTest.php
+6
-3
No files found.
tests/unit/DatabaseTestCase.php
View file @
cb8f5d70
...
...
@@ -10,6 +10,7 @@ class DatabaseTestCase extends TestCase
protected
function
setUp
()
{
parent
::
setUp
();
$databases
=
$this
->
getParam
(
'databases'
);
$this
->
database
=
$databases
[
$this
->
driverName
];
$pdo_database
=
'pdo_'
.
$this
->
driverName
;
...
...
tests/unit/MysqlTestCase.php
View file @
cb8f5d70
...
...
@@ -6,6 +6,7 @@ class MysqlTestCase extends TestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
if
(
!
extension_loaded
(
'pdo'
)
||
!
extension_loaded
(
'pdo_mysql'
))
{
$this
->
markTestSkipped
(
'pdo and pdo_mysql extensions are required.'
);
}
...
...
tests/unit/TestCase.php
View file @
cb8f5d70
...
...
@@ -2,29 +2,43 @@
namespace
yiiunit
;
/**
* This is the base class for all yii framework unit tests.
*/
class
TestCase
extends
\yii\test\TestCase
{
public
static
$params
;
protected
function
setUp
()
{
parent
::
setUp
();
}
/**
* Clean up after test.
* By default the application created with [[mockApplication]] will be destroyed.
*/
protected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
destroyApp
();
$this
->
destroyApp
lication
();
}
public
function
getParam
(
$name
,
$default
=
null
)
/**
* Returns a test configuration param from /data/config.php
* @param string $name params name
* @param mixed $default default value to use when param is not set.
* @return mixed the value of the configuration param
*/
public
function
getParam
(
$name
,
$default
=
null
)
{
if
(
self
::
$params
===
null
)
{
self
::
$params
=
require
(
__DIR__
.
'/data/config.php'
);
}
return
isset
(
self
::
$params
[
$name
])
?
self
::
$params
[
$name
]
:
$default
;
}
protected
function
mockApplication
(
$requiredConfig
=
array
())
/**
* Populates Yii::$app with a new application
* The application will be destroyed on tearDown() automatically.
* @param array $config The application configuration, if needed
*/
protected
function
mockApplication
(
$config
=
array
())
{
static
$defaultConfig
=
array
(
'id'
=>
'testapp'
,
...
...
@@ -32,10 +46,13 @@ class TestCase extends \yii\test\TestCase
);
$appClass
=
$this
->
getParam
(
'appClass'
,
'\yii\web\Application'
);
new
$appClass
(
array_merge
(
$defaultConfig
,
$
requiredC
onfig
));
new
$appClass
(
array_merge
(
$defaultConfig
,
$
c
onfig
));
}
protected
function
destroyApp
()
/**
* Destroys application in Yii::$app by setting it to null.
*/
protected
function
destroyApplication
()
{
\Yii
::
$app
=
null
;
}
...
...
tests/unit/framework/YiiBaseTest.php
View file @
cb8f5d70
...
...
@@ -11,13 +11,15 @@ class YiiBaseTest extends TestCase
{
public
$aliases
;
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
aliases
=
Yii
::
$aliases
;
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
Yii
::
$aliases
=
$this
->
aliases
;
}
...
...
tests/unit/framework/base/ComponentTest.php
View file @
cb8f5d70
...
...
@@ -24,13 +24,15 @@ class ComponentTest extends TestCase
*/
protected
$component
;
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
component
=
new
NewComponent
();
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
component
=
null
;
}
...
...
tests/unit/framework/base/DictionaryTest.php
View file @
cb8f5d70
...
...
@@ -19,8 +19,9 @@ class DictionaryTest extends \yiiunit\TestCase
protected
$item2
;
protected
$item3
;
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
dictionary
=
new
Dictionary
;
$this
->
item1
=
new
MapItem
;
$this
->
item2
=
new
MapItem
;
...
...
@@ -29,8 +30,9 @@ class DictionaryTest extends \yiiunit\TestCase
$this
->
dictionary
->
add
(
'key2'
,
$this
->
item2
);
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
dictionary
=
null
;
$this
->
item1
=
null
;
$this
->
item2
=
null
;
...
...
tests/unit/framework/base/ObjectTest.php
View file @
cb8f5d70
...
...
@@ -14,13 +14,15 @@ class ObjectTest extends TestCase
*/
protected
$object
;
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
object
=
new
NewObject
;
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
object
=
null
;
}
...
...
tests/unit/framework/base/VectorTest.php
View file @
cb8f5d70
...
...
@@ -19,8 +19,9 @@ class VectorTest extends \yiiunit\TestCase
protected
$item2
;
protected
$item3
;
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
vector
=
new
Vector
;
$this
->
item1
=
new
ListItem
;
$this
->
item2
=
new
ListItem
;
...
...
@@ -29,8 +30,9 @@ class VectorTest extends \yiiunit\TestCase
$this
->
vector
->
add
(
$this
->
item2
);
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
vector
=
null
;
$this
->
item1
=
null
;
$this
->
item2
=
null
;
...
...
tests/unit/framework/db/ActiveRecordTest.php
View file @
cb8f5d70
...
...
@@ -12,7 +12,7 @@ use yiiunit\data\ar\Item;
class
ActiveRecordTest
extends
\yiiunit\DatabaseTestCase
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
ActiveRecord
::
$db
=
$this
->
getConnection
();
...
...
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
View file @
cb8f5d70
...
...
@@ -4,7 +4,7 @@ namespace yiiunit\framework\db\sqlite;
class
SqliteActiveRecordTest
extends
\yiiunit\framework\db\ActiveRecordTest
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
$this
->
driverName
=
'sqlite'
;
parent
::
setUp
();
...
...
tests/unit/framework/db/sqlite/SqliteCommandTest.php
View file @
cb8f5d70
...
...
@@ -4,13 +4,13 @@ namespace yiiunit\framework\db\sqlite;
class
SqliteCommandTest
extends
\yiiunit\framework\db\CommandTest
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
$this
->
driverName
=
'sqlite'
;
parent
::
setUp
();
}
function
testAutoQuoting
()
public
function
testAutoQuoting
()
{
$db
=
$this
->
getConnection
(
false
);
...
...
tests/unit/framework/db/sqlite/SqliteConnectionTest.php
View file @
cb8f5d70
...
...
@@ -4,13 +4,13 @@ namespace yiiunit\framework\db\sqlite;
class
SqliteConnectionTest
extends
\yiiunit\framework\db\ConnectionTest
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
$this
->
driverName
=
'sqlite'
;
parent
::
setUp
();
}
function
testConstruct
()
public
function
testConstruct
()
{
$connection
=
$this
->
getConnection
(
false
);
$params
=
$this
->
database
;
...
...
@@ -18,7 +18,7 @@ class SqliteConnectionTest extends \yiiunit\framework\db\ConnectionTest
$this
->
assertEquals
(
$params
[
'dsn'
],
$connection
->
dsn
);
}
function
testQuoteValue
()
public
function
testQuoteValue
()
{
$connection
=
$this
->
getConnection
(
false
);
$this
->
assertEquals
(
123
,
$connection
->
quoteValue
(
123
));
...
...
@@ -26,7 +26,7 @@ class SqliteConnectionTest extends \yiiunit\framework\db\ConnectionTest
$this
->
assertEquals
(
"'It''s interesting'"
,
$connection
->
quoteValue
(
"It's interesting"
));
}
function
testQuoteTableName
()
public
function
testQuoteTableName
()
{
$connection
=
$this
->
getConnection
(
false
);
$this
->
assertEquals
(
"'table'"
,
$connection
->
quoteTableName
(
'table'
));
...
...
@@ -35,7 +35,7 @@ class SqliteConnectionTest extends \yiiunit\framework\db\ConnectionTest
$this
->
assertEquals
(
'(table)'
,
$connection
->
quoteTableName
(
'(table)'
));
}
function
testQuoteColumnName
()
public
function
testQuoteColumnName
()
{
$connection
=
$this
->
getConnection
(
false
);
$this
->
assertEquals
(
'"column"'
,
$connection
->
quoteColumnName
(
'column'
));
...
...
tests/unit/framework/db/sqlite/SqliteQueryTest.php
View file @
cb8f5d70
...
...
@@ -12,7 +12,7 @@ namespace yiiunit\framework\db\sqlite;
class
SqliteQueryTest
extends
\yiiunit\framework\db\QueryTest
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
$this
->
driverName
=
'sqlite'
;
parent
::
setUp
();
...
...
tests/unit/framework/helpers/HtmlTest.php
View file @
cb8f5d70
...
...
@@ -8,8 +8,9 @@ use yiiunit\TestCase;
class
HtmlTest
extends
TestCase
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
(
array
(
'components'
=>
array
(
'request'
=>
array
(
...
...
tests/unit/framework/helpers/VarDumperTest.php
View file @
cb8f5d70
...
...
@@ -7,6 +7,9 @@ class VarDumperTest extends \yii\test\TestCase
public
function
testDumpObject
()
{
$obj
=
new
\StdClass
();
ob_start
();
VarDumper
::
dump
(
$obj
);
$this
->
assertEquals
(
"stdClass#1
\n
(
\n
)"
,
ob_get_contents
());
ob_end_clean
();
}
}
tests/unit/framework/rbac/PhpManagerTest.php
View file @
cb8f5d70
...
...
@@ -5,12 +5,14 @@ namespace yiiunit\framework\rbac;
use
Yii
;
use
yii\rbac\PhpManager
;
require_once
(
__DIR__
.
'/ManagerTestBase.php'
);
//
require_once(__DIR__ . '/ManagerTestBase.php');
class
PhpManagerTest
extends
ManagerTestBase
{
p
ublic
function
setUp
()
p
rotected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
$authFile
=
Yii
::
$app
->
getRuntimePath
()
.
'/rbac.php'
;
@
unlink
(
$authFile
);
$this
->
auth
=
new
PhpManager
;
...
...
@@ -19,8 +21,9 @@ class PhpManagerTest extends ManagerTestBase
$this
->
prepareData
();
}
p
ublic
function
tearDown
()
p
rotected
function
tearDown
()
{
parent
::
tearDown
();
@
unlink
(
$this
->
auth
->
authFile
);
}
...
...
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