phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Class name of expected function call

Open panvid opened this issue 6 years ago • 0 comments

Q A
PHPUnit version 7.5.9
PHP version 7.3.4
Installation Method PHAR

It would be nice if the failed expection of method calling will be extended with the class, which has this function. Sometimes their are some function names in mocked classes. The now existing error message will not say which expectation is not fulfilled.

Message right now:

Expectation failed for method name is equal to 'map' when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

Better message:

Expectation failed for class `'ResponseMapper' with method name is equal to 'map' when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

Code example:

$responseMapper = $this->createMock(ResponseMapper::class);
$responseMapper->expects(self::once())->method('map')->willReturn([]);

$requestMapper = $this->createMock(RequestMapper::class);
$requestMapper->expects(self::once())->method('map')->willReturn([]);

panvid avatar May 02 '19 08:05 panvid