diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-02-07 20:38:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 20:38:19 +0100 |
commit | dcfc96f0cce0a4bc50c4c989464fbbb275ec16b0 (patch) | |
tree | f2b2738f69620cff9e8ef561b84f1f52fdda9b06 /tests/lib | |
parent | 6077003899de70c6a755b73b370f45766142090c (diff) | |
parent | 3b2d01fe8b302f54c6d69101f27bd4d67e40abbb (diff) | |
download | nextcloud-server-dcfc96f0cce0a4bc50c4c989464fbbb275ec16b0.tar.gz nextcloud-server-dcfc96f0cce0a4bc50c4c989464fbbb275ec16b0.zip |
Merge pull request #36417 from nextcloud/fix/psr-container
Make the container fully fulfill PSR container interface
Diffstat (limited to 'tests/lib')
-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); + } } |