Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-25 12:00:35 +0300
committerGitHub <noreply@github.com>2022-08-25 12:00:35 +0300
commit9b5569ff74bbc099af7c2010471bae8958aa9dd4 (patch)
tree1faaa377f2b584fa7623f69704cfdd01fff12c5f /tests
parent711a9fd209cafeee973c1f0c0924e974ffbe53f5 (diff)
parent64a748995817edbb09c41f7820ce78e71a42f96d (diff)
Merge pull request #33668 from nextcloud/tests/fix-session-middleware
Fix SessionMiddlewareTest and cover new case with reopening
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
index f9739044465..be684e36013 100644
--- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
@@ -35,7 +35,7 @@ class SessionMiddlewareTest extends \Test\TestCase {
* @UseSession
*/
public function testSessionNotClosedOnBeforeController() {
- $session = $this->getSessionMock(0);
+ $session = $this->getSessionMock(0, 1);
$this->reflector->reflect($this, __FUNCTION__);
$middleware = new SessionMiddleware($this->reflector, $session);
@@ -53,8 +53,20 @@ class SessionMiddlewareTest extends \Test\TestCase {
$middleware->afterController($this->controller, __FUNCTION__, new Response());
}
+ /**
+ * @UseSession
+ */
+ public function testSessionReopenedAndClosedOnBeforeController() {
+ $session = $this->getSessionMock(1, 1);
+
+ $this->reflector->reflect($this, __FUNCTION__);
+ $middleware = new SessionMiddleware($this->reflector, $session);
+ $middleware->beforeController($this->controller, __FUNCTION__);
+ $middleware->afterController($this->controller, __FUNCTION__, new Response());
+ }
+
public function testSessionClosedOnBeforeController() {
- $session = $this->getSessionMock(1);
+ $session = $this->getSessionMock(0);
$this->reflector->reflect($this, __FUNCTION__);
$middleware = new SessionMiddleware($this->reflector, $session);
@@ -72,13 +84,15 @@ class SessionMiddlewareTest extends \Test\TestCase {
/**
* @return mixed
*/
- private function getSessionMock($expectedCloseCount) {
+ private function getSessionMock(int $expectedCloseCount, int $expectedReopenCount = 0) {
$session = $this->getMockBuilder('\OC\Session\Memory')
->disableOriginalConstructor()
->getMock();
$session->expects($this->exactly($expectedCloseCount))
->method('close');
+ $session->expects($this->exactly($expectedReopenCount))
+ ->method('reopen');
return $session;
}
}