0
我有這樣的例子類如何使用PHPUnit模擬這些方法?
class Class
{
public function getStuff()
{
$data = $this->getData('Here');
$data2 = $this->getData('There');
return $data . ' ' . $data2;
}
public function getData($string)
{
return $string;
}
}
我希望能夠測試getStuff方法和模擬GetData方法。
嘲笑這種方法最好的方法是什麼?
由於
謝謝Gargon,這聽起來像是一個很好的解決方案。這將如何使用PHPUnit模擬對象完成? – Paulund 2013-02-17 15:29:25
我認爲它是'$ mock = $ this-> getMock('TestRepository');'。有關更多示例,請參閱[PHPUnit文檔](http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects)。 – Gargron 2013-02-17 15:35:48