diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-08-28 13:02:29 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-08-28 13:02:29 +0200 |
commit | 3f12ec95f0c220dfcfa9d495f981fee6ded4b002 (patch) | |
tree | b324750d9c482f8cb91fa800a4fa84e77320f93c | |
parent | caf32d25f8635c86ed9c230dc495a4cf6afbfe3a (diff) | |
download | nextcloud-server-3f12ec95f0c220dfcfa9d495f981fee6ded4b002.tar.gz nextcloud-server-3f12ec95f0c220dfcfa9d495f981fee6ded4b002.zip |
SessionMiddleware: declare session property
* Remove request since we don't useit
* Update tests as well
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
3 files changed, 10 insertions, 30 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 89ebc60b226..7f416c3ed90 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -284,7 +284,6 @@ class DIContainer extends SimpleContainer implements IAppContainer { $dispatcher->registerMiddleware( new SessionMiddleware( - $c->query(IRequest::class), $c->query(IControllerMethodReflector::class), $c->query(ISession::class) ) diff --git a/lib/private/AppFramework/Middleware/SessionMiddleware.php b/lib/private/AppFramework/Middleware/SessionMiddleware.php index 7b52cc1e319..3cb60874b38 100644 --- a/lib/private/AppFramework/Middleware/SessionMiddleware.php +++ b/lib/private/AppFramework/Middleware/SessionMiddleware.php @@ -34,25 +34,14 @@ use OCP\ISession; class SessionMiddleware extends Middleware { - /** - * @var IRequest - */ - private $request; - - /** - * @var ControllerMethodReflector - */ + /** @var ControllerMethodReflector */ private $reflector; - /** - * @param IRequest $request - * @param ControllerMethodReflector $reflector - */ - public function __construct(IRequest $request, - ControllerMethodReflector $reflector, - ISession $session -) { - $this->request = $request; + /** @var ISession */ + private $session; + + public function __construct(ControllerMethodReflector $reflector, + ISession $session) { $this->reflector = $reflector; $this->session = $session; } diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index 8d097e3a8a1..813b0d54dc6 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -25,20 +25,12 @@ class SessionMiddlewareTest extends \Test\TestCase { /** @var ControllerMethodReflector */ private $reflector; - /** @var Request */ - private $request; - /** @var Controller */ private $controller; protected function setUp() { parent::setUp(); - $this->request = new Request( - [], - $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder(IConfig::class)->getMock() - ); $this->reflector = new ControllerMethodReflector(); $this->controller = $this->createMock(Controller::class); } @@ -50,7 +42,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(0); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->beforeController($this->controller, __FUNCTION__); } @@ -61,7 +53,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(1); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->afterController($this->controller, __FUNCTION__, new Response()); } @@ -69,7 +61,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(1); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->beforeController($this->controller, __FUNCTION__); } @@ -77,7 +69,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $session = $this->getSessionMock(0); $this->reflector->reflect($this, __FUNCTION__); - $middleware = new SessionMiddleware($this->request, $this->reflector, $session); + $middleware = new SessionMiddleware($this->reflector, $session); $middleware->afterController($this->controller, __FUNCTION__, new Response()); } |