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
010e17d9
Commit
010e17d9
authored
Dec 25, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1612 from Ragazzo/codeception_testcase_imrovements
extended from codeception testcase, added docs
parents
5f659f90
44d28407
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
4 deletions
+52
-4
README.md
extensions/yii/codeception/README.md
+50
-3
TestCase.php
extensions/yii/codeception/TestCase.php
+2
-1
No files found.
extensions/yii/codeception/README.md
View file @
010e17d9
...
@@ -5,9 +5,8 @@ This extension provides [Codeception](http://codeception.com/) integration for t
...
@@ -5,9 +5,8 @@ This extension provides [Codeception](http://codeception.com/) integration for t
It provides classes that help with testing with codeception:
It provides classes that help with testing with codeception:
-
a base class for unit-tests:
`yii\codeception\TestCase
-
a base class for unit-tests:
`yii\codeception\TestCase
`
;
-
a base class for codeception page-objects:
`yii\codeception\BasePage`
.
-
a base class for codeception page-objects:
`yii\codeception\BasePage`
.
- a solution for testing emails
Installation
Installation
...
@@ -39,7 +38,55 @@ class to reduce code duplication. Simply extend your page object from this class
...
@@ -39,7 +38,55 @@ class to reduce code duplication. Simply extend your page object from this class
For unit testing there is a
`TestCase`
class which holds some common features like application creation before each test
For unit testing there is a
`TestCase`
class which holds some common features like application creation before each test
and application destroy after each test. You can configure a mock application using this class.
and application destroy after each test. You can configure a mock application using this class.
`
TestCase
` is extended from `
PHPUnit_Framework_TestCase
` 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:
```
php
<?php
#in your unit-test
$this
->
getModule
(
'CodeHelper'
);
#or some other module
```
You also can use all guy methods by accessing guy instance like:
```
php
<?php
$this
->
codeGuy
->
someMethodFromModule
();
```
to fire event do this:
```
php
<?php
use
Codeception\Event\TestEvent
;
public
function
testSomething
()
{
$this
->
fire
(
'myevent'
,
new
TestEvent
(
$this
));
}
```
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```
.
Execution of special tests methods is (for example on
```UserTest```
class):
```
tests\unit\models\UserTest::setUpBeforeClass();
tests\unit\models\UserTest::_before();
tests\unit\models\UserTest::setUp();
tests\unit\models\UserTest::testSomething();
tests\unit\models\UserTest::tearDown();
tests\unit\models\UserTest::_after();
tests\unit\models\UserTest::tearDownAfterClass();
```
If you use special methods dont forget to call its parent.
```
php
```
php
<?php
<?php
...
...
extensions/yii/codeception/TestCase.php
View file @
010e17d9
...
@@ -4,6 +4,7 @@ namespace yii\codeception;
...
@@ -4,6 +4,7 @@ namespace yii\codeception;
use
Yii
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
Codeception\TestCase\Test
;
/**
/**
* TestCase is the base class for all codeception unit tests
* TestCase is the base class for all codeception unit tests
...
@@ -11,7 +12,7 @@ use yii\base\InvalidConfigException;
...
@@ -11,7 +12,7 @@ use yii\base\InvalidConfigException;
* @author Mark Jebri <mark.github@yandex.ru>
* @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0
* @since 2.0
*/
*/
class
TestCase
extends
\PHPUnit_Framework_TestCase
class
TestCase
extends
Test
{
{
/**
/**
* @var array|string the application configuration that will be used for creating an application instance for each test.
* @var array|string the application configuration that will be used for creating an application instance for each test.
...
...
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