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

  1. 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 add config/test.php, config/test_db.php and web/index-test.php files. Besides you must copy require and require-dev sections ...

Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.