我一定要考類add_HookPHPUnit的模擬抽象父方法
class add_Hook extends Hooks_base
我試圖創建hooks_base的像這樣的模擬:
> $this->oHookBaseMock = $this->getMock(
> 'Hooks_base',
> array('get_database','get_arguments'),
> array(null,'null') //this are the parameters for the constructor
> );
$this->hook->expects($this->any())
->method('get_database')
->will($this->returnValue(true)
);
$this->hook->expects($this->any())
->method('get_arguments')
->will($this->returnValue($arraySImpleXmlObject)
);
,做這樣的事情:
$hook = new add_Hook($this->hook)
現在我的問題是,當我運行測試它鋼要求我的父類的兩個參數(hooks_base)
構造是這樣的
public function __construct($parameter_1, $parameter_2) {
$this->_param1 = $parameter_1;
$this->_param2 = $parameter_2;
}
我不」知道如何禁用父類的構造函數,如果我這樣做。
'add_hook'有 '私有函數的init(){$ DB = $這個 - > get_database; $ arguments = $ this-> get_arguments; }' 是的,我傳遞了兩個參數,但我不知道它爲什麼不能識別它們 – Nani