title: How to write PHP Unit Test for Static Methods
body: <p>I am very new to PHP Unit Testing. I am trying to create Unit Test for the following function:</p>
  
  <pre><code>    $context = $args[0];
  
      if (Subscriber::instance()-&gt;isSubscriber()) {
          $context['body_class'] .= ' ' . $this-&gt;bodyClass;
      }
  
      return $context;
  </code></pre>
  
  <p>Which is very simple which adds classname in array if User is subscriber. Subscriber is class which has has a static instance method which returns true or false.</p>
  
  <p>so far I have written this but I don't think this is correct:</p>
  
  <pre><code>$subscriber = $this-&gt;getMockBuilder(Subscriber::class)
      -&gt;disableOriginalConstructor()
      -&gt;setMethods(['isSubscriber'])
      -&gt;getMock();
  
  $subscriber-&gt;expects($this-&gt;once())
      -&gt;method('isSubscriber')
      -&gt;will($this-&gt;returnValue(true));
  
  $this-&gt;assertInternalType('bool',$subscriber-&gt;isSubscriber());
  </code></pre>
  
  <p>Any help would be appreciated.</p>