0

I'm using Laravel's built in unit testing to test my model validations, and I'm also using Factory Muffin to generate fake data for my models.

It's working, however I'm having a really hard time finding the complete list of generators I can use to generate random data. For example, I need to generate a random string, and I can't find the name of a generator to do that. Take this as an example:

FactoryMuffin::define('User', array(
    'email' => 'unique:email',
    'password' => 'password',
    'password_reset_code' => 'alpha_num'
));

The only thing that seems to work here is the email. Where I've defined password to be password it uses the literal string "password", even though the faker library which is what actually generates the random data has a method called password.

I've been able to get a simple list of what generators are supported by doing the following:

FactoryMuffin::getFaker();

The object returned from that has a number of methods and properties which correspond to what I can use in the define call, however the number of methods I can use is no where near what the actual Faker library provides.

Am I missing something here?

John Dorean
  • 3,744
  • 9
  • 51
  • 82

1 Answers1

0

Faker has a bunch of different providers which contain generators for different data types and locales. Have you checked which are available (under Provider), or perhaps your locale is set to something not available in the providers? (I have used email and password as above with no problems). For a random string you could use 'lexify' but this will be fixed length, or just 'word'.

softfrog
  • 60
  • 1
  • 8