Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement fixture guesser for Faker extension #4056

Closed
Ragazzo opened this issue Jun 25, 2014 · 7 comments
Closed

Implement fixture guesser for Faker extension #4056

Ragazzo opened this issue Jun 25, 2014 · 7 comments
Labels

Comments

@Ragazzo
Copy link
Contributor

Ragazzo commented Jun 25, 2014

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, or users collection in mongo, or some data in redis).

What is your thoughts @samdark @qiangxue @cebe @klimov-paul ?

@samdark
Copy link
Member

samdark commented Jun 25, 2014

I like the idea. Will definitely make developers life easier.

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Jun 26, 2014

nobody is really interested in issue ?

@cebe
Copy link
Member

cebe commented Jun 26, 2014

@Ragazzo anything to discuss here? It is a good feature request but has no prio for the release so it is open here until someone finds time to work on it. See label: "ready for adoption"

@nineinchnick
Copy link
Contributor

I'm interested but as cebe said it has low priority. Currently I do it manually in the model and that's fine, because I define such mapping once when designing the schema/creating models.

One issue is that sometimes fields are dependent, that is in my native language firstname and surname depend on gender and same gender should be passed as argument to the generators.
Such guessers should support different locale.

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Jun 27, 2014

@nineinchnick you already can create different template files when one fileds area based on other, since you can define a callback that will have as an argument $fixture containg all current fields, so you can make some conditions on $fixture['gender'] to make $fixture['first_name'] with Faker for example .

@Ragazzo
Copy link
Contributor Author

Ragazzo commented Jun 27, 2014

@cebe i am not about someone to implement this, i'll do it, i am about to discuss if one have some requests for this one to improve .

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

Issue moved to yiisoft/yii2-faker#19

@yii-bot yii-bot closed this as completed Jan 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants