In my opinion, he had no idea to never count on each method. Thus phpunit has no functionality. It can use "never" expectations only if you want to make sure completely that some method will not be called.
In any case, you can use some matches to get closer to your goal. Examples:
It was never expected that all methods of the object (it will not be possible to call any of the mocking methods):
$mock->expects($this->never()) ->method($this->anything());
So, for example, you can verify that an object will not call any method other than the verified one:
$mock = $this->getMock('Some\Tested\Class', array('testedMethod')); $mock->expects($this->never()) ->method($this->anything());
You can also try with another convention, for example. matchesRegularExpression :
$mock->expects($this->never()) ->method($this->matchesRegularExpression('/get.*/'));
For example, the above will not be executed if any receiver is called.
I know that this is not exactly what you want, but I'm afraid there is no such solution with phpunit.
source share