Faker fixture data generator
The
fzaninotto/faker
is a PHP library that generates fake data of many kinds: names, phones, addresses, random strings and numbers, and so on. It can help you to generate many randomized records for performance and logic testing. You can extend your supported types collection by writing your own formatters and generators.
In the Yii2 application skeletons, the yiisoft/yii2-faker
wrapper is included in the require-dev
section of the composer.json
file and is used for testing code (Chapter 11, Testing). This wrapper provides the FixtureController
console for use in your console application and test environment.
Getting ready
Create a new application by using composer as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
How to do it…
Open the directory
tests/codeception/templates
and add the fixture template file,users.txt
:<?php /** * @var $faker \Faker\Generator * @var $index integer */ return [ ...