Can I mock an interface implementation with PHPUnit?
The following works for me:
$myMockObj = $this->createMock(MyInterface::class);
$http_client = $this->getMockBuilder(Cpm\Http\IClient::class)
->setMockClassName('SomeClassName')
->getMock();
The setMockClassName() can be used to fix this in some circumstances.
Instead of
$http_client = $this->getMockBuilder(Cpm\Http\IClient::class);
use
$http_client = $this->getMock(Cpm\Http\IClient::class);
or
$http_client = $this->getMockBuilder(Cpm\Http\IClient::class)->getMock();
Totally works!