imanghafoori1 / eloquent-mockery

Mock your eloquent queries without the repository pattern
MIT License
129 stars 18 forks source link

Loading fake data from json #15

Closed MilesHart closed 1 year ago

MilesHart commented 1 year ago

I have a data dependent testing, so I want to use a library of JSON files, what is the best way to load from a json file into a Fake model?

`$mockFileRaw = file_get_contents(DIR . "/../testdata/ruleMock1.json");

$objMock = json_decode($mockFileRaw);

Rule::fake();

$rule = Rule::create($objMock);`

Any help would be appreciated.

imanghafoori1 commented 1 year ago

I am planning to add a feature for loading the initial data from config like php files. currently, you can loop through your data and use the FakeDB::addRow(...) method.

MilesHart commented 1 year ago

Thank you, much appreciated.