Merge pull request #8662 from nextcloud/better-debugging-unit-tests

Better debugging for "Your test case is not allowed to access the dat…
This commit is contained in:
Roeland Jago Douma 2018-03-07 21:53:34 +01:00 committed by GitHub
commit af55b03386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -46,6 +46,7 @@ class SimpleContainer extends Container implements IContainer {
/**
* @param ReflectionClass $class the class to instantiate
* @return \stdClass the created class
* @suppress PhanUndeclaredClassInstanceof
*/
private function buildClass(ReflectionClass $class) {
$constructor = $class->getConstructor();
@ -66,6 +67,12 @@ class SimpleContainer extends Container implements IContainer {
try {
$parameters[] = $this->query($resolveName);
} catch (\Exception $e) {
if (class_exists('PHPUnit_Framework_AssertionFailedError', false) &&
$e instanceof \PHPUnit_Framework_AssertionFailedError) {
// Easier debugging of "Your test case is not allowed to access the database."
throw $e;
}
// Service not found, use the default value when available
if ($parameter->isDefaultValueAvailable()) {
$parameters[] = $parameter->getDefaultValue();