DEV Community

Why I am unable to mock a php static function that is used in factory patern?

Dimitrios Desyllas on March 23, 2020

Hello May I have some help on that? Why I get `Could not load mock MyClassConsumer, cla...
Collapse
 
recursivefaults profile image
Ryan Latta

Your code looks like it has a few issues.

I think the reason you are having a specific problem right now though is you've done a spy() which is a mock(). Then you are trying to alias it, which won't work. It looks like you alias to classes that haven't been loaded. In this case you just did a spy to it, so it is loaded, so you shouldn't alias.

Hope this helps.