Dummy Data plugin - fill your app with random data that makes sense
Easy to use plugin for generating "realistic" random data for your app. It fully supports models with associations, behaviors, callbacks and validation.
Background
We often need a complete, "realistic" and/or "correct" data set during development.- Good test data help us design the work flow of the app better and decide how much data to put in each view
- When prototyping we need data to show customers how the final app will work
- Perform QA testing with "real" data before any customer is let anywhere near the app
- Last but not least - it's more enjoyable to debug and develop with a funny quote :)
Entering test data is for dummies! So we created this plugin to do it for us.
What it does
This plugin comes with a large selection of data generators (based on a fork of php-faker), including support for foreign keys using the real models if avaiable (so your associated model can change it's id in afterFind() via a behavior if you really want to do mental stuff like that).The plugin analyzes your tables and selects suitable generators for each field in each table, based on type, name and other criteria.
The generated data is saved using the correct model if available, so any validation, callbacks or behaviors will be applied as normal.
Examples
Some examples of generated data.
Generated Users:
| id | firstname | surname | username | address | phone | state | |
|---|---|---|---|---|---|---|---|
| 15 | Prescott | Swanson | prescott00 | prescott.swanson@example.com | 20469 Barnes Howeow | 555 201 640 | MD |
| 14 | Kylynn | James | kylynn87 | kylynn.james@example.com | 37060 Gibson Tunneb | 555 960 200 | ND |
| 13 | Kevin | Shaw | kevin75 | kevin.shaw@example.com | 94307 A5ev Iaxgeys | 555 539 746 | TX |
| 12 | Kelsey | Kim | kelsey32 | kelsey.kim@example.com | 38597 Stanton xriee | 555 299 355 | CT |
Generated Posts:
| id | title | color | description | created | user_id |
|---|---|---|---|---|---|
| 20 | Colossal cool chalk | Blue | Every kind of peaceful cooperation among men is primarily based on mutual trust and only secondarily on institutions such as courts of justice and police. | 2008-12-19 09:45:41 | 15 |
| 19 | Low change | White | Please Don't ask me what the score is, I'm not even sure what the game is. | 2008-12-20 06:20:27 | 12 |
| 18 | Puny hope | Red | Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. | 2009-02-09 01:08:42 | 3 |
| 17 | Old-fashioned circle | Cyan | The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is, the search for a superior moral justification for selfishness. | 2008-12-27 16:41:50 | 6 |
Default settings where used for all fields except 'User.phone' which had the field 'custom_variable' set to indicate the format of the phone number, and 'Post.created' which had the fields 'custom_min' set to '-2 months' and 'custom_max' set to 'now' to indicate any datetime in the last two months. Notice that 'Post.user_id' has automatically been correctly identified as belonging to the 'User' model.
Settings for Users table:
| name | type | allow_null | default | custom_min | custom_max | custom_var |
|---|---|---|---|---|---|---|
| address | street_address | No | ||||
| No | ||||||
| firstname | firstname | No | ||||
| phone | phone | No | 555 Xxx xxx | |||
| state | us_state_abbr | No | ||||
| surname | surname | No | ||||
| username | username | No |
Settings for Posts table:
| name | type | allow_null | default | custom_min | custom_max | custom_var |
|---|---|---|---|---|---|---|
| color | color | No | ||||
| created | datetime | No | -2months | now | ||
| description | quote | YES | ||||
| title | title | No | ||||
| user_id | BelongsTo | No | User |
Comments
Comment
1 Looks good
This should help us track those down first.
Question
2 I can't run the code for create database
cake schema run create Dummy -path plugins/dummy/config/sql
the console says: schema.php can't loaded. Can you help me? Thanks
Comment
3 Re: I can't run code for create database
Are you perhaps running windows? Then you may have to specify the path like plugins\dummy\config\sql
Comment
4 Re: I can't run the code for create database
I had the same problem. Try using the fully qualified path and it will work. For example:
cake schema run create Dummy -path /cake_1.2.2.8120/app/plugins/dummy/config/sql
Comment
5 undefined method
Call to undefined method Company::table() in \myapp\plugins\dummy\vendors\phpfaker\lib\company.php on line 30I couldn't access the dummy_fields until I commented out all the arrays relating to 'Company' in the plugin. After that I could access the field options but still can not create a User that belongs to Company.
Comment
6 abercrombie fitch polo
thanks for your share.i will see next time,looking for your next article.
maybe you can seeabercrombie fitch polo