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
107eb811
Commit
107eb811
authored
Jan 26, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added titles, fixed formatting
parent
67aff101
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
README.md
extensions/codeception/README.md
+27
-12
No files found.
extensions/codeception/README.md
View file @
107eb811
...
@@ -41,6 +41,9 @@ and application destroy after each test. You can configure a mock application us
...
@@ -41,6 +41,9 @@ and application destroy after each test. You can configure a mock application us
`TestCase`
is extended from
`Codeception\TestCase\Case`
so all methods and assertions are available.
`TestCase`
is extended from
`Codeception\TestCase\Case`
so all methods and assertions are available.
You may use codeception modules and fire events in your test, just use methods:
You may use codeception modules and fire events in your test, just use methods:
Getting Codeception modules
---------------------------
```
php
```
php
<?php
<?php
#in your unit-test
#in your unit-test
...
@@ -53,6 +56,8 @@ You also can use all guy methods by accessing guy instance like:
...
@@ -53,6 +56,8 @@ You also can use all guy methods by accessing guy instance like:
<?php
<?php
$this
->
codeGuy
->
someMethodFromModule
();
$this
->
codeGuy
->
someMethodFromModule
();
```
```
Codeception events
------------------
to fire event do this:
to fire event do this:
...
@@ -68,6 +73,10 @@ public function testSomething()
...
@@ -68,6 +73,10 @@ public function testSomething()
this event can be catched in modules and helpers. If your test is in the group, then event name will be followed by the groupname,
this event can be catched in modules and helpers. If your test is in the group, then event name will be followed by the groupname,
for example
```myevent.somegroup```
.
for example
```myevent.somegroup```
.
Special test methods chain call
-------------------------------
Execution of special tests methods is (for example on
```UserTest```
class):
Execution of special tests methods is (for example on
```UserTest```
class):
```
```
...
@@ -88,31 +97,33 @@ tests\unit\models\UserTest::tearDownAfterClass();
...
@@ -88,31 +97,33 @@ tests\unit\models\UserTest::tearDownAfterClass();
If you use special methods dont forget to call its parent.
If you use special methods dont forget to call its parent.
Customizing application config
------------------------------
```
php
```
php
<?php
<?php
SomeConsoleTest
extends
\yii\codeception\TestCase
SomeConsoleTest
extends
\yii\codeception\TestCase
{
{
// this is the config file to load as application config
// this is the config file to load as application config
public
$appConfig
=
'@app/path/to/my/custom/config/for/test.php'
;
public
$appConfig
=
'@app/path/to/my/custom/config/for/test.php'
;
}
}
```
```
The
`$appConfig`
property could be an array or valid alias, pointing to file that returns config array. You can s
ep
cify
The
`$appConfig`
property could be an array or valid alias, pointing to file that returns config array. You can s
pe
cify
application class in the config, for example for testing console commands/features you can create
`_console.php`
config under
application class in the config, for example for testing console commands/features you can create
`_console.php`
config under
`tests/unit`
folder like this:
`tests/unit`
folder like this:
```
php
```
php
return
yii\helpers\ArrayHelper
::
merge
(
return
yii\helpers\ArrayHelper
::
merge
(
require
(
__DIR__
.
'/../../config/console.php'
),
require
(
__DIR__
.
'/../../config/console.php'
),
require
(
__DIR__
.
'/../_config.php'
),
require
(
__DIR__
.
'/../_config.php'
),
[
[
'components'
=>
[
'class'
=>
'yii\console\Application'
,
//override console components if needed
'components'
=>
[
],
//override console components if needed
]
],
]
);
);
```
```
...
@@ -124,14 +135,15 @@ use \yii\codeception\TestCase;
...
@@ -124,14 +135,15 @@ use \yii\codeception\TestCase;
class
ConsoleTestCase
extends
TestCase
class
ConsoleTestCase
extends
TestCase
{
{
public
$appConfig
=
'@tests/unit/_console.php'
;
public
$appConfig
=
'@tests/unit/_console.php'
;
}
}
```
```
You can extend other console tests cases from this basic
`ConsoleTestCase`
.
You can extend other console tests cases from this basic
`ConsoleTestCase`
.
Reconfiguring components for test
---------------------------------
You also can reconfigure some components for tests, for this purpose in your
`setUp`
method of your test case
You also can reconfigure some components for tests, for this purpose in your
`setUp`
method of your test case
you can do this for example:
you can do this for example:
...
@@ -193,7 +205,10 @@ class SomeMyTest extends TestCase
...
@@ -193,7 +205,10 @@ class SomeMyTest extends TestCase
}
}
}
}
```
Additional debug output
-----------------------
Because of Codeception buffers all output you can't make simple
`var_dump()`
in the TestCase, instead you need to use
Because of Codeception buffers all output you can't make simple
`var_dump()`
in the TestCase, instead you need to use
`Codeception\Util\Debug::debug()`
function and then run test with
`--debug`
key, for example:
`Codeception\Util\Debug::debug()`
function and then run test with
`--debug`
key, for example:
...
...
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