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

[5.6] Add faker helper #23451

Closed
wants to merge 3 commits into from
Closed

[5.6] Add faker helper #23451

wants to merge 3 commits into from

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Mar 9, 2018

I'm currently adding a new section mockup to an existing app. This helper has been indispensable with creating fake data in my views as quickly as possible to get a visual to the client.

Directly in my mockup view I can...

<span>{{ faker()->firstName }}</span>

This makes for some serious Rapid Mockup Development™️ but is also easy enough to add to an app's helpers if not wanted in the core.

This only works in dev, not in production as faker is a dev only requirement - but I think that makes sense for a mockup helper.

@browner12
Copy link
Contributor

Is this for normal copy that is not part of a database entry? Like your on-page lorem ipsum?

@timacdonald
Copy link
Member Author

timacdonald commented Mar 9, 2018

yea exactly, this is for creating fake data to populate mockups. Data that does not yet exist in the app's database.

@timacdonald
Copy link
Member Author

I know there aren't really any tests around the helpers, but I had a silly syntax error in my first PR, so I added a test to be extra safe!

@deleugpn
Copy link
Contributor

deleugpn commented Mar 9, 2018

Thanks for the idea =)

public function testFakerIsCreated()
{
$this->assertTrue(faker() instanceof \Faker\Generator);
$this->assertTrue(faker('fr_FR') instanceof \Faker\Generator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use $this->assertInstanceOf('\Faker\Generator', faker()); here for clearer errors 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I’m camping for the weekend, but if there is interest in this and it hasn’t been canned by the boss, I’ll tweak this on Monday (Aus Time).
Thanks for the tip!

@taylorotwell
Copy link
Member

I want to try to avoid defining too many new helpers. Feel free to define it in your application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants