|
|
|
|
@ -114,7 +114,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
* @dataProvider isLoggedInData |
|
|
|
|
*/ |
|
|
|
|
public function testIsLoggedIn($isLoggedIn) { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
|
|
|
|
|
$manager = $this->createMock(Manager::class); |
|
|
|
|
|
|
|
|
|
@ -132,7 +132,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testSetUser() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$session->expects($this->once()) |
|
|
|
|
->method('set') |
|
|
|
|
->with('user_id', 'foo'); |
|
|
|
|
@ -151,7 +151,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testLoginValidPasswordEnabled() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$session->expects($this->once()) |
|
|
|
|
->method('regenerateId'); |
|
|
|
|
$this->tokenProvider->expects($this->once()) |
|
|
|
|
@ -228,7 +228,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
public function testLoginValidPasswordDisabled() { |
|
|
|
|
$this->expectException(LoginException::class); |
|
|
|
|
|
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$session->expects($this->never()) |
|
|
|
|
->method('set'); |
|
|
|
|
$session->expects($this->once()) |
|
|
|
|
@ -270,7 +270,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testLoginInvalidPassword() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
//keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -313,7 +313,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testPasswordlessLoginNoLastCheckUpdate(): void { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
// Keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -350,7 +350,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testLoginLastCheckUpdate(): void { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
// Keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -387,7 +387,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testLoginNonExisting() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$manager = $this->createMock(Manager::class); |
|
|
|
|
$userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); |
|
|
|
|
|
|
|
|
|
@ -607,7 +607,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testRememberLoginValidToken() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
//keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -696,7 +696,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testRememberLoginInvalidSessionToken() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
//keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -760,7 +760,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testRememberLoginInvalidToken() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
//keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -812,7 +812,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testRememberLoginInvalidUser() { |
|
|
|
|
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); |
|
|
|
|
$session = $this->createMock(Memory::class); |
|
|
|
|
$managerMethods = get_class_methods(Manager::class); |
|
|
|
|
//keep following methods intact in order to ensure hooks are working |
|
|
|
|
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); |
|
|
|
|
@ -872,7 +872,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
return $users[$uid]; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$session = new Memory(''); |
|
|
|
|
$session = new Memory(); |
|
|
|
|
$session->set('user_id', 'foo'); |
|
|
|
|
$userSession = $this->getMockBuilder(Session::class) |
|
|
|
|
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) |
|
|
|
|
@ -885,7 +885,7 @@ class SessionTest extends \Test\TestCase { |
|
|
|
|
|
|
|
|
|
$this->assertEquals($users['foo'], $userSession->getUser()); |
|
|
|
|
|
|
|
|
|
$session2 = new Memory(''); |
|
|
|
|
$session2 = new Memory(); |
|
|
|
|
$session2->set('user_id', 'bar'); |
|
|
|
|
$userSession->setSession($session2); |
|
|
|
|
$this->assertEquals($users['bar'], $userSession->getUser()); |
|
|
|
|
|