aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework/Http/DispatcherTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/AppFramework/Http/DispatcherTest.php')
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php59
1 files changed, 25 insertions, 34 deletions
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 7415ecd9486..4ed6627891c 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -8,6 +8,7 @@
namespace Test\AppFramework\Http;
+use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
@@ -20,8 +21,10 @@ use OCP\AppFramework\Http\ParameterOutOfRangeException;
use OCP\AppFramework\Http\Response;
use OCP\Diagnostics\IEventLogger;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IRequestId;
+use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
@@ -63,6 +66,10 @@ class TestController extends Controller {
'text' => [$int, $bool, $test, $test2]
]);
}
+
+ public function test(): Response {
+ return new DataResponse();
+ }
}
/**
@@ -104,33 +111,17 @@ class DispatcherTest extends \Test\TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->eventLogger = $this->createMock(IEventLogger::class);
$this->container = $this->createMock(ContainerInterface::class);
- $app = $this->getMockBuilder(
- 'OC\AppFramework\DependencyInjection\DIContainer')
- ->disableOriginalConstructor()
- ->getMock();
- $request = $this->getMockBuilder(
- '\OC\AppFramework\Http\Request')
- ->disableOriginalConstructor()
- ->getMock();
- $this->http = $this->getMockBuilder(
- \OC\AppFramework\Http::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $app = $this->createMock(DIContainer::class);
+ $request = $this->createMock(Request::class);
+ $this->http = $this->createMock(\OC\AppFramework\Http::class);
- $this->middlewareDispatcher = $this->getMockBuilder(
- '\OC\AppFramework\Middleware\MiddlewareDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
- $this->controller = $this->getMockBuilder(
- '\OCP\AppFramework\Controller')
- ->setMethods([$this->controllerMethod])
+ $this->middlewareDispatcher = $this->createMock(MiddlewareDispatcher::class);
+ $this->controller = $this->getMockBuilder(TestController::class)
+ ->onlyMethods([$this->controllerMethod])
->setConstructorArgs([$app, $request])
->getMock();
- $this->request = $this->getMockBuilder(
- '\OC\AppFramework\Http\Request')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->request = $this->createMock(Request::class);
$this->reflector = new ControllerMethodReflector();
@@ -140,7 +131,7 @@ class DispatcherTest extends \Test\TestCase {
$this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container,
@@ -166,7 +157,7 @@ class DispatcherTest extends \Test\TestCase {
->method('beforeController')
->with($this->equalTo($this->controller),
$this->equalTo($this->controllerMethod))
- ->will($this->throwException($exception));
+ ->willThrowException($exception);
if ($catchEx) {
$this->middlewareDispatcher->expects($this->once())
->method('afterException')
@@ -317,7 +308,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -350,7 +341,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -386,7 +377,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -421,7 +412,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -457,7 +448,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -492,7 +483,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -530,7 +521,7 @@ class DispatcherTest extends \Test\TestCase {
$this->http, $this->middlewareDispatcher, $this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container
@@ -545,7 +536,7 @@ class DispatcherTest extends \Test\TestCase {
}
- public function rangeDataProvider(): array {
+ public static function rangeDataProvider(): array {
return [
[PHP_INT_MIN, PHP_INT_MAX, 42, false],
[0, 12, -5, true],
@@ -574,7 +565,7 @@ class DispatcherTest extends \Test\TestCase {
$this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container,