Beispiel #1
0
 public function testRememberLoginInvalidUser()
 {
     $session = $this->getMock('\\OC\\Session\\Memory', array(), array(''));
     $session->expects($this->never())->method('set');
     $session->expects($this->once())->method('regenerateId');
     $managerMethods = get_class_methods('\\OC\\User\\Manager');
     //keep following methods intact in order to ensure hooks are
     //working
     $doNotMock = array('__construct', 'emit', 'listen');
     foreach ($doNotMock as $methodName) {
         $i = array_search($methodName, $managerMethods, true);
         if ($i !== false) {
             unset($managerMethods[$i]);
         }
     }
     $manager = $this->getMock('\\OC\\User\\Manager', $managerMethods, array());
     $backend = $this->getMock('\\Test\\Util\\User\\Dummy');
     $user = $this->getMock('\\OC\\User\\User', array(), array('foo', $backend));
     $user->expects($this->never())->method('getUID');
     $user->expects($this->never())->method('updateLastLoginTimestamp');
     $manager->expects($this->once())->method('get')->with('foo')->will($this->returnValue(null));
     //prepare login token
     $token = 'goodToken';
     \OC::$server->getConfig()->setUserValue('foo', 'login_token', $token, time());
     $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config);
     $granted = $userSession->loginWithCookie('foo', $token);
     $this->assertSame($granted, false);
 }