mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-14 05:08:42 +08:00
docs fix
This commit is contained in:
@@ -36,16 +36,17 @@ To use this extension, simply add the following code in your application config
|
|||||||
```
|
```
|
||||||
Set valid ```test``` alias in your console config, for example for ```basic``` application template, this should be added
|
Set valid ```test``` alias in your console config, for example for ```basic``` application template, this should be added
|
||||||
to ```console.php``` config: ```Yii::setAlias('tests', __DIR__ . '/../tests');```
|
to ```console.php``` config: ```Yii::setAlias('tests', __DIR__ . '/../tests');```
|
||||||
To start using this command you need to be familiar (read guide) for the Faker library and
|
To start using this command you need to be familiar (read guide) for the [Faker](https://github.com/fzaninotto/Faker) library and
|
||||||
generate fixtures template files, according to the given format:
|
generate fixtures template files, according to the given format:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
~~~
|
||||||
#users.php file under template path (by default @tests/unit/fixtures/templates)
|
#users.php file under template path (by default @tests/unit/fixtures/templates)
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'table_column0' => 'faker_formatter',
|
'table_column0' => 'faker_formatter',
|
||||||
...
|
...
|
||||||
'table_columnN' => 'other_faker_formatter
|
'table_columnN' => 'other_faker_formatter'
|
||||||
'table_columnN+1' => function ($fixture, $faker, $index) {
|
'table_columnN+1' => function ($fixture, $faker, $index) {
|
||||||
//set needed fixture fields based on different conditions
|
//set needed fixture fields based on different conditions
|
||||||
return $fixture;
|
return $fixture;
|
||||||
@@ -75,7 +76,7 @@ php yii faker users
|
|||||||
|
|
||||||
In the code above "users" is template name, after this command run, new file named same as template
|
In the code above "users" is template name, after this command run, new file named same as template
|
||||||
will be created under the fixtures path (by default ```@tests/unit/fixtures```) folder.
|
will be created under the fixtures path (by default ```@tests/unit/fixtures```) folder.
|
||||||
You can generate fixtures for all templates by specifying keyword "all_fixtures"
|
You can generate fixtures for all templates by specifying keyword ```all_fixtures```.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
php yii faker/generate all_fixtures
|
php yii faker/generate all_fixtures
|
||||||
|
|||||||
Reference in New Issue
Block a user