laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Cannot fill model _id property in unit test

Open dave101ua opened this issue 2 years ago • 0 comments

Hello,

In unit test I want to mock collection of models which are requested from Mongo DB Problem is that I need to fill _id property as well and it fails with message
Error: Call to a member function connection() on null

Here is how I do it

    $modelFactory = new MyModelFactory();
    $model = $modelFactory->make(['_id'=>'bestproduct2022']);

In my case _id is not autogenerated, it is filled manually. Is there any workarounds possible in order to fill this property ?

Thank you

dave101ua avatar Feb 02 '22 08:02 dave101ua