我有一個類:PHPUnit模擬具有參考參數的控制器嗎?
class Hello {
function doSomething(&$reference, $normalParameter) {
// do stuff...
}
}
然後,我有一個控制器:
class myController {
function goNowAction() {
$hello = new Hello();
$var = new stdClass();
$var2 = new stdClass();
$bla = $hello->doSomething($var, $var2);
}
}
的 「吉奧」 行動我打電話用我的測試,像這樣:
$this->dispatch('/my/go-now');
我想嘲笑「doSomething」方法,因此它返回單詞「GONOW!」。作爲結果。我怎麼做?
我試圖創建一個模擬
$mock = $this->getMock('Hello ', array('doSomething'));
,然後加回:
$stub->expects($this->any())
->method('discoverRoute2')
->will($this->returnValue("GONOW!"));
但我難倒就如何掛鉤該到實際控制人是我m測試。我需要做些什麼才能真正調用模擬方法?