-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fabricator class #2936
Fabricator class #2936
Conversation
@lonnieezell et al, still a fair amount of work to do but please take a look at the concept and weigh in on if you consider this something for the core framework. |
@MGatner yes, I would love to have something like this. I've wanted it numerous times. :) Only catch - it should be able to work for those who don't want to use Composer, unfortunately. Maybe a super simple class that spits out some semi-random stuff for a handful of common elements if Faker isn't present? Another thought is to make it a Project instead. I don't have a problem with those requiring Composer. |
I understand the need to support non-Composer installations, but just to push back a little:
|
That's a fair point that testing already requires composer. That's convincing enough for me. :) |
I think this is ready! @lonnieezell take a look if you would. And anyone else who sees this, I'd appreciate feedback/suggestions/critiques. A lot harder to change things once they are released so let's make this good up front. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in all - I really like it. I was a little concerned at first about having to provide the formatters in each class. I could see that being a giant PITA to maintain consistency. but I think your solution of the fake()
method in the model works well.
Thanks! Re: formatters, I wanted to be sure there was a way people could run distinct tests without modifying models. I will probably always use extended models in Tests\Support with the Looking over your comments now. |
Requested changes implemented! |
Looks great to me. I'm assuming nothing else you want to do to it? If so - feel free to merge! |
Description
This is something I keep needing and finally set out to write a module for it, then realized it might be appropriate for the core framework.
Fabricator is a test utility used to create faked data based on Model definitions. Similar to Laravel's "factories" it creates instances of
$model->returnType
with random data generated by Faker.Checklist:
create()
method for DB inserts and "faux" inserts