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
3bdb6c31
Commit
3bdb6c31
authored
May 11, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed indentation in test files
parent
cb8f5d70
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
55 deletions
+55
-55
DatabaseTestCase.php
tests/unit/DatabaseTestCase.php
+41
-41
TestCase.php
tests/unit/TestCase.php
+2
-2
config.php
tests/unit/data/config.php
+12
-12
No files found.
tests/unit/DatabaseTestCase.php
View file @
3bdb6c31
...
@@ -4,48 +4,48 @@ namespace yiiunit;
...
@@ -4,48 +4,48 @@ namespace yiiunit;
class
DatabaseTestCase
extends
TestCase
class
DatabaseTestCase
extends
TestCase
{
{
protected
$database
;
protected
$database
;
protected
$driverName
=
'mysql'
;
protected
$driverName
=
'mysql'
;
protected
$db
;
protected
$db
;
protected
function
setUp
()
protected
function
setUp
()
{
{
parent
::
setUp
();
parent
::
setUp
();
$databases
=
$this
->
getParam
(
'databases'
);
$databases
=
$this
->
getParam
(
'databases'
);
$this
->
database
=
$databases
[
$this
->
driverName
];
$this
->
database
=
$databases
[
$this
->
driverName
];
$pdo_database
=
'pdo_'
.
$this
->
driverName
;
$pdo_database
=
'pdo_'
.
$this
->
driverName
;
if
(
!
extension_loaded
(
'pdo'
)
||
!
extension_loaded
(
$pdo_database
))
{
if
(
!
extension_loaded
(
'pdo'
)
||
!
extension_loaded
(
$pdo_database
))
{
$this
->
markTestSkipped
(
'pdo and pdo_'
.
$pdo_database
.
' extension are required.'
);
$this
->
markTestSkipped
(
'pdo and pdo_'
.
$pdo_database
.
' extension are required.'
);
}
}
}
}
/**
/**
* @param bool $reset whether to clean up the test database
* @param bool $reset whether to clean up the test database
* @param bool $open whether to open and populate test database
* @param bool $open whether to open and populate test database
* @return \yii\db\Connection
* @return \yii\db\Connection
*/
*/
public
function
getConnection
(
$reset
=
true
,
$open
=
true
)
public
function
getConnection
(
$reset
=
true
,
$open
=
true
)
{
{
if
(
!
$reset
&&
$this
->
db
)
{
if
(
!
$reset
&&
$this
->
db
)
{
return
$this
->
db
;
return
$this
->
db
;
}
}
$db
=
new
\yii\db\Connection
;
$db
=
new
\yii\db\Connection
;
$db
->
dsn
=
$this
->
database
[
'dsn'
];
$db
->
dsn
=
$this
->
database
[
'dsn'
];
if
(
isset
(
$this
->
database
[
'username'
]))
{
if
(
isset
(
$this
->
database
[
'username'
]))
{
$db
->
username
=
$this
->
database
[
'username'
];
$db
->
username
=
$this
->
database
[
'username'
];
$db
->
password
=
$this
->
database
[
'password'
];
$db
->
password
=
$this
->
database
[
'password'
];
}
}
if
(
$open
)
{
if
(
$open
)
{
$db
->
open
();
$db
->
open
();
$lines
=
explode
(
';'
,
file_get_contents
(
$this
->
database
[
'fixture'
]));
$lines
=
explode
(
';'
,
file_get_contents
(
$this
->
database
[
'fixture'
]));
foreach
(
$lines
as
$line
)
{
foreach
(
$lines
as
$line
)
{
if
(
trim
(
$line
)
!==
''
)
{
if
(
trim
(
$line
)
!==
''
)
{
$db
->
pdo
->
exec
(
$line
);
$db
->
pdo
->
exec
(
$line
);
}
}
}
}
}
}
$this
->
db
=
$db
;
$this
->
db
=
$db
;
return
$db
;
return
$db
;
}
}
}
}
tests/unit/TestCase.php
View file @
3bdb6c31
...
@@ -44,11 +44,11 @@ class TestCase extends \yii\test\TestCase
...
@@ -44,11 +44,11 @@ class TestCase extends \yii\test\TestCase
'id'
=>
'testapp'
,
'id'
=>
'testapp'
,
'basePath'
=>
__DIR__
,
'basePath'
=>
__DIR__
,
);
);
$appClass
=
$this
->
getParam
(
'appClass'
,
'\yii\web\Application'
);
$appClass
=
$this
->
getParam
(
'appClass'
,
'\yii\web\Application'
);
new
$appClass
(
array_merge
(
$defaultConfig
,
$config
));
new
$appClass
(
array_merge
(
$defaultConfig
,
$config
));
}
}
/**
/**
* Destroys application in Yii::$app by setting it to null.
* Destroys application in Yii::$app by setting it to null.
*/
*/
...
...
tests/unit/data/config.php
View file @
3bdb6c31
...
@@ -3,16 +3,16 @@
...
@@ -3,16 +3,16 @@
return
array
(
return
array
(
//'appClass' => '\yii\web\Application',
//'appClass' => '\yii\web\Application',
'appClass'
=>
'\yii\console\Application'
,
'appClass'
=>
'\yii\console\Application'
,
'databases'
=>
array
(
'databases'
=>
array
(
'mysql'
=>
array
(
'mysql'
=>
array
(
'dsn'
=>
'mysql:host=127.0.0.1;dbname=yiitest'
,
'dsn'
=>
'mysql:host=127.0.0.1;dbname=yiitest'
,
'username'
=>
'travis'
,
'username'
=>
'travis'
,
'password'
=>
''
,
'password'
=>
''
,
'fixture'
=>
__DIR__
.
'/mysql.sql'
,
'fixture'
=>
__DIR__
.
'/mysql.sql'
,
),
),
'sqlite'
=>
array
(
'sqlite'
=>
array
(
'dsn'
=>
'sqlite::memory:'
,
'dsn'
=>
'sqlite::memory:'
,
'fixture'
=>
__DIR__
.
'/sqlite.sql'
,
'fixture'
=>
__DIR__
.
'/sqlite.sql'
,
),
),
),
),
);
);
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