I\'m trying to migrate a bunch of tests from SimpleTest to PHPUnit and I was wondering if there is an equivalent for SimpleTest\'s partial mocks.
Update: I can\'t seem t
PHPUnit_Framework_TestCase::getMock is deprecated since phpunit 5.4. We can use setMethods
instead.
setMethods(array $methods) can be called on the Mock Builder object to specify the methods that are to be replaced with a configurable test double. The behavior of the other methods is not changed. If you call setMethods(null), then no methods will be replaced.
https://phpunit.de/manual/current/en/test-doubles.html
$observer = $this->getMockBuilder(Observer::class)
->setMethods(['update'])
->getMock();
Note that the above getMock
is PHPUnit_Framework_MockObject_MockBuilder::getMock
. (phpunit5.6)