I am very new to PHP Unit Testing. I am trying to create Unit Test for the following function:
$context = $args[0];
if (Subscriber::instance()->isSubscriber()) {
$context['body_class'] .= ' ' . $this->bodyClass;
}
return $context;
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.
so far I have written this but I don't think this is correct:
$subscriber = $this->getMockBuilder(Subscriber::class)
->disableOriginalConstructor()
->setMethods(['isSubscriber'])
->getMock();
$subscriber->expects($this->once())
->method('isSubscriber')
->will($this->returnValue(true));
$this->assertInternalType('bool',$subscriber->isSubscriber());
Any help would be appreciated.