Codeception Extension for Yii 2 =============================== This extension provides [Codeception](http://codeception.com/) integration for the Yii Framework 2.0. It provides classes that help with testing with codeception: - a base class for unit-tests: `yii\codeception\TestCase - a base class for codeception page-objects: `yii\codeception\BasePage`. - a solution for testing emails Installation ------------ The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Either run ``` php composer.phar require yiisoft/yii2-codeception "*" ``` or add ```json "yiisoft/yii2-codeception": "*" ``` to the require section of your composer.json. Usage ----- When using codeception page-objects they have some similar code, this code was extracted and put into the `BasePage` class to reduce code duplication. Simply extend your page object from this class, like it is done in `yii2-app-basic` and `yii2-app-advanced` boilerplates. 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. `TestCase` is extended from `PHPUnit_Framework_TestCase` so all methods and assertions are available. ```php [ 'mail' => [ 'useFileTransport' => true, ], ] ]; } ``` 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: ```php 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) yii\web\User Object ( [identityClass] => app\models\User [enableAutoLogin] => [loginUrl] => Array ( [0] => site/login ) [identityCookie] => Array ( [name] => _identity [httpOnly] => 1 ) [authTimeout] => [autoRenewCookie] => 1 [idVar] => __id [authTimeoutVar] => __expire [returnUrlVar] => __returnUrl [_access:yii\web\User:private] => Array ( ) [_identity:yii\web\User:private] => [_events:yii\base\Component:private] => [_behaviors:yii\base\Component:private] => ) ``` For further instructions refer to the testing section in the [Yii Definitive Guide](https://github.com/yiisoft/yii2/blob/master/docs/guide/testing.md).