I have a problem with a mocking parent method, here is an example:
class PathProvider
{
public function getPath()
{
return isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
}
}
class Uri extends PathProvider
{
public function getParam($param)
{
$path = $this->getPath();
if ($path == $param)
return 'OK';
else
return 'Bad';
}
}
And now I want the mock getPath () method and the getParam () call method, which retrieves the mocked value.
$mock = $this->getMock('PathProvider');
$mock->expects($this->any())
->method('getPath')
->will($this->returnValue('/panel2.0/user/index/id/5'));
I wrote this part, but I do not know how to pass this mocked value to the testing method.
source
share