dongmaxi6763 2014-10-18 23:06
浏览 16
已采纳

工厂松饼发电机列表

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?

  • 写回答

1条回答 默认 最新

  • dongxiee0744 2014-11-13 13:53
    关注

    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'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)