ReturnValueMap uses identity operator (===) on parameters
t-schroeder opened this issue · 1 comments
t-schroeder commented
Q | A |
---|---|
PHPUnit version | 5.7.19 |
PHP version | 5.6.30 |
Installation Method | Composer |
ReturnValueMap requires that you use the same instances of all parameters defined by it when calling your mocked method. That's because the parameters are compared using ===
.
ReturnValueMap.php:
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
{
$parameterCount = count($invocation->parameters);
foreach ($this->valueMap as $map) {
if (!is_array($map) || $parameterCount != count($map) - 1) {
continue;
}
$return = array_pop($map);
if ($invocation->parameters === $map) {
return $return;
}
}
return;
}
I would like to be able to call my mocked method with parameters that are equal to those specified in my ReturnValueMap, but not identical (i.e. the way Parity does it).
t-schroeder commented
Sorry, I just realized this is a duplicate of #318.