O'Reilly logo

Mastering Yii by Charles R. Portwood II

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

Fixtures

The last testing component we'll talk about in this chapter is fixtures. Fixtures are an important part of testing as they enable us to set up our application state to a known and precise state before running our unit tests. Unlike these other test types, however, fixtures are provided directly by Yii2 and integrate into Codeception via the Yii2 Codeception module.

Tip

In this section, we'll be using the source code on the fixtures branch located at https://github.com/masteringyii/chapter10.

Creating fixtures

To get started with using fixtures, we first need to install the required composer dependencies and then add some configuration to our config/console.php file:

  1. First, we need to make sure that the yii2-faker composer package is installed: ...

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