matthisstenius started a new conversation Handle Instantiating An Eloquent Model With Phpspec
I have a simple service class that is responsible for instantiating an Eloquent model and calling a repository with that model. I want to test this with phpspec but can't figure out a good way to do this. I get an error when the test is instantiating the model because it cant' find a local testing DB.
I don't want to test any relationships or the actual active record part of the model since this is not the job for phpspec. I just want to be able the create an instance of my model so i can test that the call to the API is being made.
Any one know how i should tackle this?
The issue is that i'm using Laravels filesystem and just want to mock that implementation. But as stated above it seems to be hard because you have to use the Filesystem factory in the Laravel application. So if i mock the Local Filesystem implementation my class won't accept that because it expects an implementation of the Filesystem factory.
Hi! I've run into some issues while trying to mock the Laravel 5 filesystem.
In order to use the filesystem you have to inject
This gives me trouble when i want to mock the Filesystem in phpspec. I cant just mock the local Filesystem implementation because my class expects an instance of the Factory interface. And i can't simply mock the Factory because it just contains one disk method that is responsible of giving the actual Filesystem implementation.
I want to set expectations on my filesystem mock to make sure methods such as
files() gets called.
Any ideas on how to mock the actual filesystem would be greatly appreciated.
@RemiC Cool! Thanks ;) Will play around with it a bit and see if i can come up with something that works.
@RemiC Hi, really nice package. have started implementing it on a new side project and so far it feels really natural :) Just a question. Is there some way to not have the value objects be mutable? So far as i can tell there is now way now to make the value objects and entities immutable?