$client = Mockery::mock();
$client->shouldReceive('send')->andThrow($error)->andReturn(true);
不幸的是,它只返回true,但不会先抛出异常。如何在第一次调用时抛出异常,然后在方法的第二次调用时返回值?
修改:
如果我手动修改Mockery\Expectation.php
并设置$_throw
= true
。
$client->shouldReceive('send')->twice()->andReturn($error, true);
答案 0 :(得分:24)
$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);