Beispiel #1
0
 public function testActiveUserAfterSetSession()
 {
     $users = array('foo' => new User('foo', null), 'bar' => new User('bar', null));
     $manager = $this->getMockBuilder('\\OC\\User\\Manager')->disableOriginalConstructor()->getMock();
     $manager->expects($this->any())->method('get')->will($this->returnCallback(function ($uid) use($users) {
         return $users[$uid];
     }));
     $session = new Memory('');
     $session->set('user_id', 'foo');
     $userSession = $this->getMockBuilder('\\OC\\User\\Session')->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config])->setMethods(['validateSession'])->getMock();
     $userSession->expects($this->any())->method('validateSession');
     $this->assertEquals($users['foo'], $userSession->getUser());
     $session2 = new Memory('');
     $session2->set('user_id', 'bar');
     $userSession->setSession($session2);
     $this->assertEquals($users['bar'], $userSession->getUser());
 }
Beispiel #2
0
	public function testActiveUserAfterSetSession() {
		$users = array(
			'foo' => new User('foo', null),
			'bar' => new User('bar', null)
		);

		$manager = $this->getMockBuilder('\OC\User\Manager')
			->disableOriginalConstructor()
			->getMock();

		$manager->expects($this->any())
			->method('get')
			->will($this->returnCallback(function ($uid) use ($users) {
				return $users[$uid];
			}));

		$session = new Memory('');
		$session->set('user_id', 'foo');
		$userSession = new \OC\User\Session($manager, $session);
		$this->assertEquals($users['foo'], $userSession->getUser());

		$session2 = new Memory('');
		$session2->set('user_id', 'bar');
		$userSession->setSession($session2);
		$this->assertEquals($users['bar'], $userSession->getUser());
	}