PHP - Mockery accessing to static property when overload a class

64 Views Asked by At

I'm trying to write a Test for a esential part of the App, but I don't want to refactor the whole app.

I have "hard" dependency between classes. I know, I know, Don't ask me, It's already that way.

I've found a way to mock all the instances of a class using overload

Mock:mock('overload:MyClass')

BUT! I have something like this

class MyClass {
  public static $type =  'OneType;
}

And when it is trying to access to that property, I get "Access to undeclared static property MyClass::$type"

I understant, if I want to access to static properties and methods I can use "alias", but if I want to "mock all instances of a class" I should use "overload". However, I need to do both!

How can I solve this situation?

0

There are 0 best solutions below