Skip to content
Snippets Groups Projects
Commit ddd6a67d authored by Robin Appelman's avatar Robin Appelman
Browse files

Handle exceptions thrown during hooks when running unit tests

parent 3ed6ed3c
No related branches found
No related tags found
No related merge requests found
......@@ -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
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment