Fix session tests

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-05-15 11:32:25 +02:00
parent 466297829e
commit 991d9b5c3a
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 11 additions and 2 deletions

View File

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