yii2-faker
yii2-faker copied to clipboard
Implement fixture guesser for Faker extension
This issue has originally been reported by @Ragazzo at https://github.com/yiisoft/yii2/issues/4056. Moved here by @cebe.
In the Faker
there are some column guessers like this one and this, their purpose is to help user to avoid manual matching attribute names on correct providers, because in most cases username
or email
in table or other storage means simple user name and email that is userName
and email
providers in Faker
.
In this way it would be great if we will implement such functionality for generating templates based on some tables or mongo collections or other storages. So overall usage of command is :
//generate fixture template for users table, basing on some guessing mechanism
php yii fixture/template users
and if for example users
table contains email
/ username
/ first_name
/ last_name
and other, the resulting fixture template file will be like this :
//keys are attributes names, while values are anonymous functions or faker provider method names
return [
'username' => 'userName',
'first_name' => 'firstName',
'email' => 'email',
'last_name' => 'lastName'
];
Overall what we achive :
- more automating generation in testing to help user;
- we can implement different guessing strategies;
- we can implement different storages that provides metadata for particular fixture template (it can be
users
table, orusers
collection in mongo, or some data in redis).
What is your thoughts @samdark @qiangxue @cebe @klimov-paul ?