1
所以基本上我試圖嘲笑我的依賴關係在控制器上,我想使用Mockery的ordered()
功能。嘲諷命令嘲笑
$request = \Mockery::mock('Silhouette\Http\Request');
$response = \Mockery::mock('Silhouette\Http\Response');
$response->shouldReceive("setContent")->ordered();
$db = \Mockery::mock('Dabble\Database');
$configData = \Mockery::mock('Silhouette\Configuration\ConfigurationData');
$configData->shouldReceive("get")->andReturn(array(18, 23))->ordered();
上述測試是成功的,即使所述$configData->get()
被在控制器$response->setContent()
之前調用。 此外,如果我扭轉嘲笑的順序,我仍然geta成功的測試。
$request = \Mockery::mock('Silhouette\Http\Request');
$db = \Mockery::mock('Dabble\Database');
$configData = \Mockery::mock('Silhouette\Configuration\ConfigurationData');
$configData->shouldReceive("get")->andReturn(array(18, 23))->ordered();
$response = \Mockery::mock('Silhouette\Http\Response');
$response->shouldReceive("setContent")->ordered();
任何想法我在做什麼錯在這裏?謝謝
聲明,這種方法有望在相對於類似的標記方法以特定的順序被調用。 所以它們表示同一個模擬對象的方法。謝謝! – 2014-09-03 14:16:36