Creating a mock in phpunit without mocking any methods?

前端 未结 5 1745
情深已故
情深已故 2020-12-29 01:53

When I\'m unit-testing my php code with PHPUnit, I\'m trying to figure out the right way to mock an object without mocking any of its methods.

The problem is that if

5条回答
  •  自闭症患者
    2020-12-29 02:33

    Another hacky, but succinct solution is simply to list the magic constructor as one of the mocked methods:

    $mock = $this->getMock('MyClass', array('__construct'));
    

提交回复
热议问题