Skip to content

Conversation

@GeniJaho
Copy link
Collaborator

@GeniJaho GeniJaho commented Jan 23, 2023

The fake() helper is used by default in the UserFactory in fresh Laravel 9 installations. It seems like it should be the default way to access the faker instance from L9 onwards. Plus it really reads nicely. Would it make sense to replace it in all factories?

TODO:

  • skip $this->faker->randomEnum(...).

@driftingly
Copy link
Owner

@GeniJaho can you expand on the TODO there "skip $this->faker->randomEnum(...)."?

@GeniJaho
Copy link
Collaborator Author

@GeniJaho can you expand on the TODO there "skip $this->faker->randomEnum(...)."?

I'm using this package https://github.com/spatie/laravel-enum#faker-provider in one of my projects, and I'm using $this->faker->randomEnum(...) from its faker provider. However, it does not work if we swap it with fake()->randomEnum(...).

@driftingly driftingly merged commit 21c7c03 into driftingly:main Feb 27, 2023
@driftingly
Copy link
Owner

Thanks @GeniJaho 🙌

@GeniJaho GeniJaho deleted the replace-faker-instance-with-helper-function branch April 11, 2024 17:03
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.

2 participants