Mock object without mocking methods
When mocking an object with PHPUnit, all methods are automatically also mocked. When you only want to cancel the constructor, but want the methods still to be used, you can define that with using null
as parameter for setMethods
.
$handler = $this
->getMockBuilder('MyCustomHandler')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
This way the methods won’t be mocked.