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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
c70f5a1b
Commit
c70f5a1b
authored
Dec 17, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished codeception extension
parent
5e78fe7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
23 deletions
+36
-23
_bootstrap.php
apps/basic/tests/unit/_bootstrap.php
+7
-2
BasePage.php
extensions/yii/codeception/BasePage.php
+9
-4
TestCase.php
extensions/yii/codeception/TestCase.php
+20
-17
No files found.
apps/basic/tests/unit/_bootstrap.php
View file @
c70f5a1b
<?php
// add unit testing specific bootstrap code here
\ No newline at end of file
// add unit testing specific bootstrap code here
yii\codeception\TestCase
::
$applicationConfig
=
yii\helpers\ArrayHelper
::
merge
(
require
(
__DIR__
.
'/../../config/web.php'
),
require
(
__DIR__
.
'/../../config/codeception/unit.php'
)
);
\ No newline at end of file
extensions/yii/codeception/BasePage.php
View file @
c70f5a1b
...
...
@@ -2,13 +2,18 @@
namespace
yii\codeception
;
use
Codeception\AbstractGuy
;
/**
* Represents a web page to test
*
* Pages extend from this class and declare UI map for this page via
* static properties. CSS or XPath allowed.
*
* Here is an example:
*
*
Declare UI map for this page here. CSS or XPath allowed.
*
```php
* public static $usernameField = '#username';
* public static $formSubmitButton = "#mainForm input[type=submit]";
* ```
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
...
...
@@ -20,7 +25,7 @@ abstract class BasePage
*/
public
static
$URL
=
''
;
/**
* @var AbstractGuy
* @var
\Codeception\
AbstractGuy
*/
protected
$guy
;
...
...
extensions/yii/codeception/TestCase.php
View file @
c70f5a1b
...
...
@@ -3,20 +3,24 @@
namespace
yii\codeception
;
use
Yii
;
use
yii\helpers\ArrayHelper
;
/**
* TestCase is the base class for all codeception unit tests
*
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
*/
class
TestCase
extends
\PHPUnit_Framework_TestCase
{
/**
* Your application base config that will be used for creating application each time before test.
*
@var array|string
Your application base config that will be used for creating application each time before test.
* This can be an array or alias, pointing to the config file. For example for console application it can be
* '@tests/unit/console_bootstrap.php' that can be similar to existing unit tests bootstrap file.
* @var mixed
*/
protected
$baseConfig
=
'@app/config/web.php'
;
public
static
$applicationConfig
=
'@app/config/web.php'
;
/**
* Your application config, will be merged with base config when creating application. Can be an alias too.
* @var mixed
* @var array|string Your application config, will be merged with base config when creating application. Can be an alias too.
*/
protected
$config
=
[];
...
...
@@ -24,13 +28,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
* Created application class
* @var string
*/
protected
$appClass
=
'yii\web\Application'
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
}
protected
$applicationClass
=
'yii\web\Application'
;
protected
function
tearDown
()
{
...
...
@@ -38,16 +36,21 @@ class TestCase extends \PHPUnit_Framework_TestCase
parent
::
tearDown
();
}
/**
* Sets up `Yii::$app`.
*/
protected
function
mockApplication
()
{
$baseConfig
=
is_array
(
$this
->
baseConfig
)
?
$this
->
baseConfig
:
require
(
Yii
::
getAlias
(
$this
->
base
Config
));
$baseConfig
=
is_array
(
static
::
$applicationConfig
)
?
static
::
$applicationConfig
:
require
(
Yii
::
getAlias
(
static
::
$application
Config
));
$config
=
is_array
(
$this
->
config
)
?
$this
->
config
:
require
(
Yii
::
getAlias
(
$this
->
config
));
new
$this
->
app
Class
(
\yii\helpers\
ArrayHelper
::
merge
(
$baseConfig
,
$config
));
new
$this
->
app
licationClass
(
ArrayHelper
::
merge
(
$baseConfig
,
$config
));
}
/**
* Destroys an application created via [[mockApplication]].
*/
protected
function
destroyApplication
()
{
\Yii
::
$app
=
null
;
}
}
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