From 97c4c00e3f3e1bc9561953fb110b83c11eda1d2c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 5 Mar 2018 16:06:29 +0100 Subject: [PATCH 1/4] Better debugging for "Your test case is not allowed to access the database." Signed-off-by: Joas Schilling --- lib/private/AppFramework/Utility/SimpleContainer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index b86d333926..97cb772e3b 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -66,6 +66,12 @@ class SimpleContainer extends Container implements IContainer { try { $parameters[] = $this->query($resolveName); } catch (\Exception $e) { + if (class_exists("PHPUnit_Framework_AssertionFailedError") && + $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(); From 09d8387b005d86dbd519cefe70082456953de311 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 6 Mar 2018 13:56:44 +0100 Subject: [PATCH 2/4] Try without autoloading Signed-off-by: Joas Schilling --- lib/private/AppFramework/Utility/SimpleContainer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 97cb772e3b..c2c2964b02 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -66,7 +66,7 @@ class SimpleContainer extends Container implements IContainer { try { $parameters[] = $this->query($resolveName); } catch (\Exception $e) { - if (class_exists("PHPUnit_Framework_AssertionFailedError") && + 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; From 559978c50eb837f6168a84bd536ff0824ad88d78 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 6 Mar 2018 14:02:50 +0100 Subject: [PATCH 3/4] Suppress phan error Signed-off-by: Joas Schilling --- lib/private/AppFramework/Utility/SimpleContainer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index c2c2964b02..de2f496c4a 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -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(); From 1dd40b1f45cb7c2002bb574f779a411ec8050530 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 7 Mar 2018 16:50:18 +0100 Subject: [PATCH 4/4] Single quotes Signed-off-by: Joas Schilling --- lib/private/AppFramework/Utility/SimpleContainer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index de2f496c4a..e96f24ed28 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -67,7 +67,7 @@ class SimpleContainer extends Container implements IContainer { try { $parameters[] = $this->query($resolveName); } catch (\Exception $e) { - if (class_exists("PHPUnit_Framework_AssertionFailedError", false) && + 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;