Testing application with Codeception
By default, the basic and advanced Yii2 application skeletons use Codeception as a testing framework. Codeception supports writing of unit, functional, and acceptance tests out of the box. For unit tests, it uses the PHPUnit test framework, which will be covered in the next recipe.
Getting ready
- Create a new
yii2-app-basic
application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.Note
Note: If your use version 2.0.9 (or earlier) of the basic application just upgrade manually
tests
directory, and also addconfig/test.php
,config/test_db.php
andweb/index-test.php
files. Besides you must copyrequire
andrequire-dev
sections ofcomposer.json
file and runcomposer updat
e
. - Create and apply the following migration:
<?php use yii\db\Migration; class m160309_070856_create_post extends Migration { public function up() { $this->createTable('{...