diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/Utility/SimpleContainerTest.php | 27 |
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); + } } |