18
$client = Mockery::mock();
$client->shouldReceive('send')->andThrow($error)->andReturn(true);

不幸的是,它只返回 true 而不会首先抛出异常。如何在第一次调用时抛出异常,然后在第二次调用该方法时返回值?

编辑

如果我手动编辑Mockery\Expectation.php和设置$_throw = true.

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

1 回答 1

32
$client->shouldReceive('send')->once()->andThrow($error);
$client->shouldReceive('send')->once()->andReturn(true);
于 2013-07-21T00:22:09.217 回答