From 991d9b5c3acb21b65aed9c52c4b18c47ff1951e2 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 15 May 2018 11:32:25 +0200 Subject: [PATCH] Fix session tests Signed-off-by: Roeland Jago Douma --- tests/lib/User/SessionTest.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 9a5a45c46c..24677b57dd 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -581,6 +581,8 @@ class SessionTest extends \Test\TestCase { $tokenObject->expects($this->once()) ->method('getLoginName') ->willReturn('foobar'); + $tokenObject->method('getId') + ->willReturn(42); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) @@ -593,15 +595,22 @@ class SessionTest extends \Test\TestCase { ->method('setMagicInCookie'); $user->expects($this->once()) ->method('updateLastLoginTimestamp'); - $session->expects($this->once()) + $setUID = false; + $session ->method('set') - ->with('user_id', 'foo'); + ->will($this->returnCallback(function ($k, $v) use (&$setUID) { + if ($k === 'user_id' && $v === 'foo') { + $setUID = true; + } + })); $userSession->expects($this->once()) ->method('setLoginName') ->willReturn('foobar'); $granted = $userSession->loginWithCookie('foo', $token, $oldSessionId); + $this->assertTrue($setUID); + $this->assertTrue($granted); }