Book Image

Learning Yii Testing

Book Image

Learning Yii Testing

Overview of this book

Table of Contents (16 chapters)
Learning Yii Testing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing Codeception in Yii 2


Now that we've seen what we can theoretically do with Codeception, let's move on and install it.

Yii comes with its own Codeception extension that provides a base class for unit tests (yii\codeception\TestCase), a class for tests that require database interaction (yii\codeception\DbTestCase), and a base class for Codeception page objects (yii\codeception\BasePage).

As usual, our preferred method is using Composer:

$ composer require "codeception/codeception: 2.0.*" --prefer-dist --dev

There's a specific reason to use –prefer-dist; if you're using Git, you can get into a hairy situation with Git submodules (but again excluding the /vendor folder should solve most of these problems). To avoid repeating it every time we use Composer, just add the following to your composer.json file:

// composer.json

{
    "config": {
        "preferred-install": "dist"
    }
}

Also, remember that using composer install will not work if you've added the component manually to your...