I need to mock static method of class. But in phpunit:4 and later versions mocking static method is impossible (I get exception with message 'Static method "findBy" cannot be invoked on mock object'). How i need configure mock to get successful test?
I tried create mock class without phphunit manually. Somethig like tests/Mocks/MyClass.php
that extends abstract class and implement my static method/
interface IdentityInterface
{
// this method calling first in other component
public static function findBy(string $number, ?string $trunk): ?IdentityInterface;
}
abstract class Identity implements IdentityInterface
{
// this method and other calling after findBy method
public function getName(): string
{
return $this->name; // need to cover
}
}
My static method must return instance of itself to use other internal methods that i need to cover.