I\'m trying to use PHPUnit\'s returnValueMap() to stub out the results of a read. It isn\'t yielding the expected results, but an equivalent returnCallback() does. I\'ve made
I had the same problem and eventually found out that returnValueMap() has to map all parameters of your function, including optional ones, then the desired return value.
Example function from Zend Framework:
public function getParam($key, $default = null)
{
$key = (string) $key;
if (isset($this->_params[$key])) {
return $this->_params[$key];
}
return $default;
}
Has to mapped like this:
$request->expects($this->any())
->method('getParam')
->will($this->returnValueMap(array(array($param, null, $value))));
Without the null in the middle, it won't work.