2013-07-20 36 views
12
$client = Mockery::mock(); 
$client->shouldReceive('send')->andThrow($error)->andReturn(true); 

不幸的是,它只返回true,但不是首先拋出異常。如何在第一次調用時拋出異常,然後在第二次調用該方法時返回值?第一次嘲諷然後返回第二次電話返回值

編輯

這工作如果我手動編輯Mockery\Expectation.php並設置$_throw = true

$client->shouldReceive('send')->twice()->andReturn($error, true); 

回答

21
$client->shouldReceive('send')->once()->andThrow($error); 
$client->shouldReceive('send')->once()->andReturn(true); 
相關問題