是否有一种简单的方法可以预期在抛出的异常堆栈中更深层次的异常?
//
//Code:
//
try {
throw Unauthorized();
} catch(Unauthorized $e) {
// here I put source exception and wrap it with another one
throw CommandFailed("message",0,$e);
}
//
// Test
//
$this->assertException(Unauthorized::class); // this won't work
// the only way I can think of. It works but kind of too wordy.
try {
//...code...
} catch(CommandFailed $e) {
$this->assertEquals(Unauthorized::class, get_class($e->getPrevious()));
}