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

pcmagas

Dimitrios Desyllas

Posted on March 23, 2020

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

Hello May I have some help on that?

I have the following class:


public function MyClass
{
  public static foo():string
  {
    // Some logic there
    // This is a dummy value just for explaining the problem
    return 'n123';
  }

  public static factory():MyClass
  {
    return new MyClass();
  }
}

Also I have the following class as well:


class MyClassConsumer
💖 💪 🙅 🚩
pcmagas
Dimitrios Desyllas

Posted on March 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related