```php function didExceptionHappen($func, $exceptionType) { try { $func(); return false; } catch (Throwable $e) { if ($e instanceof $exceptionType) { return true; } throw $e; } } ``` PHPunit's expect exception is not useful: * https://stackoverflow.com/questions/14561908/phpunit-doesnt-continue-test-after-expecting-an-exception * https://github.com/sebastianbergmann/phpunit/issues/6187