diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-02-14 10:12:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 10:12:19 +0100 |
commit | a705132c8d9eef7f4d0f030be76a2015a0b8ab6f (patch) | |
tree | 659bbf33a1a17abb79175f96057319c194bb0b88 /tests | |
parent | 39b13e096ccfd23d8b9b4527e098f53b7535f26b (diff) | |
parent | b911da3e1eedff9f7df683889f0d425d47a6fd1c (diff) | |
download | nextcloud-server-a705132c8d9eef7f4d0f030be76a2015a0b8ab6f.tar.gz nextcloud-server-a705132c8d9eef7f4d0f030be76a2015a0b8ab6f.zip |
Merge pull request #36656 from nextcloud/route-instrumentation
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/Routing/RoutingTest.php | 52 | ||||
-rw-r--r-- | tests/lib/Route/RouterTest.php | 12 |
2 files changed, 57 insertions, 7 deletions
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index 22037c31d0d..d7fde02dbcb 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -6,8 +6,12 @@ use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Routing\RouteConfig; use OC\Route\Route; use OC\Route\Router; +use OCP\Diagnostics\IEventLogger; +use OCP\IConfig; +use OCP\IRequest; use OCP\Route\IRouter; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; class RoutingTest extends \Test\TestCase { @@ -133,7 +137,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // load route configuration @@ -154,7 +164,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // load route configuration @@ -214,7 +230,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // we expect create to be called once: @@ -264,7 +286,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // we expect create to be called once: @@ -291,7 +319,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // route mocks @@ -338,7 +372,13 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) + ->setConstructorArgs([ + $this->createMock(LoggerInterface::class), + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class) + ]) ->getMock(); // route mocks diff --git a/tests/lib/Route/RouterTest.php b/tests/lib/Route/RouterTest.php index 44fef6f1d4f..301058f74a6 100644 --- a/tests/lib/Route/RouterTest.php +++ b/tests/lib/Route/RouterTest.php @@ -24,6 +24,10 @@ declare(strict_types=1); namespace Test\Route; use OC\Route\Router; +use OCP\Diagnostics\IEventLogger; +use OCP\IConfig; +use OCP\IRequest; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -44,7 +48,13 @@ class RouterTest extends TestCase { $this->fail('Unexpected info log: '.(string)($data['exception'] ?? $message)); } ); - $router = new Router($logger); + $router = new Router( + $logger, + $this->createMock(IRequest::class), + $this->createMock(IConfig::class), + $this->createMock(IEventLogger::class), + $this->createMock(ContainerInterface::class), + ); $this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index')); |