mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Handle exceptions thrown during hooks when running unit tests
This commit is contained in:
parent
3ed6ed3c36
commit
ddd6a67d2a
2 changed files with 11 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
|||
* slots and emitting signals.
|
||||
*/
|
||||
class OC_Hook{
|
||||
public static $thrownExceptions = [];
|
||||
|
||||
static private $registered = array();
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +79,7 @@ class OC_Hook{
|
|||
try {
|
||||
call_user_func( array( $i["class"], $i["name"] ), $params );
|
||||
} catch (Exception $e){
|
||||
self::$thrownExceptions[] = $e;
|
||||
OC_Log::write('hook',
|
||||
'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(),
|
||||
OC_Log::ERROR);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
|
|||
});
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
$hookExceptions = \OC_Hook::$thrownExceptions;
|
||||
\OC_Hook::$thrownExceptions = [];
|
||||
if(!empty($hookExceptions)) {
|
||||
throw $hookExceptions[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier as uniqid() is not reliable sometimes
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue