Merge pull request #16913 from nextcloud/fix/declare_members
SessionMiddleware: declare session property
This commit is contained in:
commit
130fdf5006
|
@ -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)
|
||||
)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue