Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kmuenkel/concept-factory
Auto-generate dummy-data for tests with cascading realistic relationships based on Model configs
https://github.com/kmuenkel/concept-factory
composer data-generator laravel phpunit
Last synced: about 2 months ago
JSON representation
Auto-generate dummy-data for tests with cascading realistic relationships based on Model configs
- Host: GitHub
- URL: https://github.com/kmuenkel/concept-factory
- Owner: kmuenkel
- License: mit
- Created: 2020-01-28T19:55:32.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-11T21:24:08.000Z (over 4 years ago)
- Last Synced: 2024-11-16T17:45:03.986Z (3 months ago)
- Topics: composer, data-generator, laravel, phpunit
- Language: PHP
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
The problem: Per the Scientific Method, PhpUnit tests need to be in control of the source data feeding the behavior being tested. And Model Factories, while handy, don't supply realistic relationships between records. You can make them, of course, by having them reference eachother in the foreign key fields. But then you risk infinite recursion if your database isn't normalized properly. And that still doesn't address the problem that one table doesn't necessarily represent one idea, necessitating multiple Model Factories for the same Model, and that starts to get a little messy.
i.e. a 'user' table might be a student, or it might be an admin. If it's a student, that means the user record must have particular values therein, and must have a particular relationship with a 'class' record, the 'class' record must have a corresponding 'school', and so-on.
What if you could just run something like `php artisan concept:generate student`, and have all dependent-records of dependant-records generate for you on a recursive fashion?Taking the example a bit further, if you have a lecture 'attendee' record, that means a 'student' with a related 'school' record. And there's a many-to-many relationship with a 'lecture' record... which _also_ links to a 'school' record. So what if our dummy-data generator were smart enough to leverage the _same_ school record for both?
That is the purpose of this package. To generate _mostly_ random, _mostly_ lorem ipsum dummy-data with **cascading realistic relationships** for the purposes of automated tests or local QA.
***
Similar to how Model classes encompass a database table, a Concept class encompasses a conceptual entity. They can be just as lightweight, and are structured in a similar manor, starting with a base Model name, a list of relationships that needed to be loaded with it, and the option to override the Model's relationship method with one of it's own, that could serve back a nested Concept object. It's the ability to replace a relationship with another Concept that allows this tool to become exponentially smarter the more it's leveraged.