Answer the question
In order to leave comments, you need to log in
How do you test static methods?
I came across an article on testing static methods via Mock or Stub
https://sebastian-bergmann.de/archives/883-Stubbin... but it deals with the case for PhpUnit 3.5. Accordingly, it does not work in 4.5.
I would like to hear how you test static methods?
Answer the question
In order to leave comments, you need to log in
How do you test static methods?
Depends on your architecture, I use a "wrapper" class with an overload of the desired method (I use the same trick to change the call of the functions of the parent class)
Something like this:
class A { // "родной" класс
static function static_call ()
{
echo 'static_call a';
}
}
class B extends A{ // "обертка" для тестирования
static function static_call ()
{
echo 'static_call b';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question