Book Image

Mastering Yii

By : Charles R. Portwood ll
Book Image

Mastering Yii

By: Charles R. Portwood ll

Overview of this book

The successor of Yii Framework 1.1, Yii 2 is a complete rewrite of Yii Framework, one of the most popular PHP 5 frameworks around for making modern web applications. The update embraces the best practices and protocols established with newer versions of PHP, while still maintaining the simple, fast, and extendable behavior found in its predecessor. This book has been written to enhance your skills and knowledge with Yii Framework 2. Starting with configuration and how to initialize new projects, you’ll learn how to configure, manage, and use every aspect of Yii2 from Gii, DAO, Query Builder, Active Record, and migrations, to asset manager. You'll also discover how to automatically test your code using codeception. With this book by your side, you’ll have all the skills you need to quickly create rich modern web and console applications with Yii 2.
Table of Contents (20 chapters)
Mastering Yii
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
5
Modules, Widgets, and Helpers
13
Debugging and Deploying
Index

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:

    $ composer require --dev yii2-faker
    
  2. Alternatively, the yii2-faker extension can be installed by adding the following to the require-dev section of composer.json and then by executing composer update:

    "yiisoft/yii2-faker": "*",
  3. Then, we need to add...