I already follow the tutorial in GitHub - yiisoft/yii2-faker: Yii 2 Faker extension and read this thread Yii Faker Not Working.
But, my output data display the wrong result.
It displays 1 instead of randomly generated data.
Is there anything step that I missed?
I am using yii2 advanced version.
This is my console/config/main.php
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'on beforeAction' => function ($event) {
},
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'controllerMap' => [
'fixture' => [
// 'class' => 'yii\console\controllers\FixtureController',
// 'namespace' => 'common\fixtures',
'class' => 'yii\faker\FixtureController',
'templatePath' => '@common/tests/templates/fixtures',
'fixtureDataPath' => '@common/tests/fixtures/data',
],
],
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
];
This is my common/tests/templates/fixtures/pendonor.php
return [
'id_jenis_donasi' => $faker->numberBetween($min=1, $max=2),
'nama' => $faker->name,
'alamat' => $faker->address,
'telp' => $faker->phoneNumber,
];
when I run
php yii fixture/generate pendonor
New data file generated in common/tests/fixtures/data/pendonor.php
<?php
return [
'pendonor0' => 1,
'pendonor1' => 1,
];