summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFerdinand Thiessen <rpm@fthiessen.de>2023-01-28 03:41:24 +0100
committerFerdinand Thiessen <rpm@fthiessen.de>2023-02-06 14:16:35 +0100
commitba8a50c0591c14a63947bda81915988fb03067fe (patch)
tree2656c23a7201bfd7d2b6440af3a3f527a7e3ade0 /tests
parent3473b69ad2df1862225cbdff884cf94996f554fc (diff)
downloadnextcloud-server-ba8a50c0591c14a63947bda81915988fb03067fe.tar.gz
nextcloud-server-ba8a50c0591c14a63947bda81915988fb03067fe.zip
fix: Throw `NotFoundExceptionInterface` to fulfill PSR container interface if class not found
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Utility/SimpleContainerTest.php27
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
index 8caaf517f5c..61b3299671b 100644
--- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php
+++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace Test\AppFramework\Utility;
use OC\AppFramework\Utility\SimpleContainer;
+use Psr\Container\NotFoundExceptionInterface;
interface TestInterface {
}
@@ -76,11 +77,31 @@ class SimpleContainerTest extends \Test\TestCase {
}
-
+ /**
+ * Test querying a class that is not registered without autoload enabled
+ */
public function testNothingRegistered() {
- $this->expectException(\OCP\AppFramework\QueryException::class);
+ try {
+ $this->container->query('something really hard', false);
+ $this->fail('Expected `QueryException` exception was not thrown');
+ } catch (\Throwable $exception) {
+ $this->assertInstanceOf(\OCP\AppFramework\QueryException::class, $exception);
+ $this->assertInstanceOf(NotFoundExceptionInterface::class, $exception);
+ }
+ }
+
- $this->container->query('something really hard');
+ /**
+ * Test querying a class that is not registered with autoload enabled
+ */
+ public function testNothingRegistered_autoload() {
+ try {
+ $this->container->query('something really hard');
+ $this->fail('Expected `QueryException` exception was not thrown');
+ } catch (\Throwable $exception) {
+ $this->assertInstanceOf(\OCP\AppFramework\QueryException::class, $exception);
+ $this->assertInstanceOf(NotFoundExceptionInterface::class, $exception);
+ }
}