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
22b95607
Commit
22b95607
authored
Dec 03, 2013
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added testcase for unit tests, bootstrap files improved, tests inherited from base testcase
parent
fdd24fe3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
27 deletions
+64
-27
_bootstrap.php
apps/basic/tests/_bootstrap.php
+2
-0
TestCase.php
apps/basic/tests/_helpers/TestCase.php
+56
-0
_bootstrap.php
apps/basic/tests/unit/_bootstrap.php
+1
-3
ContactFormTest.php
apps/basic/tests/unit/models/ContactFormTest.php
+1
-9
LoginFormTest.php
apps/basic/tests/unit/models/LoginFormTest.php
+1
-10
UserTest.php
apps/basic/tests/unit/models/UserTest.php
+3
-5
No files found.
apps/basic/tests/_bootstrap.php
View file @
22b95607
<?php
<?php
require_once
(
__DIR__
.
'/yii_bootstrap.php'
);
apps/basic/tests/_helpers/TestCase.php
0 → 100644
View file @
22b95607
<?php
namespace
tests\_helpers
;
class
TestCase
extends
\PHPUnit_Framework_TestCase
{
/**
* Your application config, will be merged with base config when creating application.
* @var array
*/
protected
$config
=
array
();
/**
* Created application class
* @var string
*/
protected
$appClass
=
'\yii\web\Application'
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
}
protected
function
tearDown
()
{
$this
->
destroyApplication
();
parent
::
tearDown
();
}
protected
function
mockApplication
()
{
$baseConfig
=
require
(
__DIR__
.
'/../unit/_bootstrap.php'
);
$config
=
\yii\helpers\ArrayHelper
::
merge
(
$baseConfig
,
$this
->
config
);
new
$this
->
appClass
(
$config
);
}
protected
function
destroyApplication
()
{
\Yii
::
$app
=
null
;
}
/**
* Use this method when you need to dump variables with var_dump function.
* This is caused by the buffering output of the codeception.
* @param mixed $var
*/
protected
static
function
varDump
(
$var
)
{
ob_start
();
var_dump
(
$var
);
\Codeception\Util\Debug
::
debug
(
ob_get_clean
());
}
}
apps/basic/tests/unit/_bootstrap.php
View file @
22b95607
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
$config
=
require
(
__DIR__
.
'/../yii_bootstrap.php'
);
$config
=
require
(
__DIR__
.
'/../yii_bootstrap.php'
);
$config
=
yii\helpers\ArrayHelper
::
merge
(
return
yii\helpers\ArrayHelper
::
merge
(
$config
,
$config
,
require
(
__DIR__
.
'/../../config/codeception/unit.php'
)
require
(
__DIR__
.
'/../../config/codeception/unit.php'
)
);
);
$application
=
new
yii\web\Application
(
$config
);
apps/basic/tests/unit/models/ContactFormTest.php
View file @
22b95607
...
@@ -2,15 +2,7 @@
...
@@ -2,15 +2,7 @@
namespace
tests\unit\models
;
namespace
tests\unit\models
;
class
ContactFormTest
extends
\
PHPUnit_Framework_
TestCase
class
ContactFormTest
extends
\
tests\_helpers\
TestCase
{
{
protected
function
setUp
()
{
}
protected
function
tearDown
()
{
}
}
}
apps/basic/tests/unit/models/LoginFormTest.php
View file @
22b95607
...
@@ -2,15 +2,7 @@
...
@@ -2,15 +2,7 @@
namespace
tests\unit\models
;
namespace
tests\unit\models
;
class
LoginFormTest
extends
\
PHPUnit_Framework_
TestCase
class
LoginFormTest
extends
\
tests\_helpers\
TestCase
{
{
protected
function
setUp
()
{
}
protected
function
tearDown
()
{
}
}
}
\ No newline at end of file
apps/basic/tests/unit/models/UserTest.php
View file @
22b95607
...
@@ -4,7 +4,7 @@ namespace tests\unit\models;
...
@@ -4,7 +4,7 @@ namespace tests\unit\models;
#use yii\test\DbTestTrait;
#use yii\test\DbTestTrait;
class
UserTest
extends
\
PHPUnit_Framework_
TestCase
class
UserTest
extends
\
tests\_helpers\
TestCase
{
{
use
DbTestTrait
;
use
DbTestTrait
;
...
@@ -12,16 +12,14 @@ class UserTest extends \PHPUnit_Framework_TestCase
...
@@ -12,16 +12,14 @@ class UserTest extends \PHPUnit_Framework_TestCase
protected
function
setUp
()
protected
function
setUp
()
{
{
/*
/*
*
* you can load fixtures in this way
* you can load fixtures in this way
*
*
parent::setUp();
$this->loadFixtures([
$this->loadFixtures([
'tbl_user',
'tbl_user',
]);
]);
*/
*/
}
}
protected
function
tearDown
()
{
}
}
}
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