2011-09-19 30 views
0

在下面的代碼中,testFunctionA輸出true,而testFunctionB輸出null。這是一個已知的錯誤,我可以繞過它而無需擺脫我的@depends標誌?@depends標誌打破我的PHPUnit函數中的參數

public function testFunctionA($x = true) { 
    var_dump($x); // outputs true 
} 

/* 
* @depends testFunctionA 
*/ 
public function testFunctionB($y = true) { 
    var_dump($y); // outputs NULL 
} 

回答

4

@depends註釋比你想象的要多一點。主要來自testFunctionA的返回值傳遞給testFunctionB。由於testFunctionA不返回任何內容,因此testFunctionB正在傳遞一個空值。

有關更多信息,請參閱PHPUnit test dependencies文檔。

向testFunctionB提供null參數和根本沒有參數是有區別的。只有在沒有提供的情況下,$ y默認爲true。