Merge pull request #16913 from nextcloud/fix/declare_members

SessionMiddleware: declare session property
This commit is contained in:
Roeland Jago Douma 2019-08-29 09:54:45 +02:00 committed by GitHub
commit 130fdf5006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 30 deletions

View File

@ -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)
)

View File

@ -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;
}

View File

@ -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());
}