O'Reilly logo

Learning Yii Testing by Matteo Pescarin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required