public function testSetUser() { $session = $this->getMock('\\OC\\Session\\Memory', array(), array('')); $session->expects($this->once())->method('set')->with('user_id', 'foo'); $manager = $this->getMock('\\OC\\User\\Manager'); $backend = $this->getMock('\\Test\\Util\\User\\Dummy'); $user = $this->getMock('\\OC\\User\\User', array(), array('foo', $backend)); $user->expects($this->once())->method('getUID')->will($this->returnValue('foo')); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config); $userSession->setUser($user); }
public function testSetUser() { $session = $this->getMock('\\OC\\Session\\Memory', array(), array('')); $session->expects($this->once())->method('set')->with('user_id', 'foo'); $manager = $this->getMock('\\OC\\User\\Manager'); $backend = $this->getMock('OC_User_Dummy'); $user = $this->getMock('\\OC\\User\\User', array(), array('foo', $backend)); $user->expects($this->once())->method('getUID')->will($this->returnValue('foo')); //also set the \OC::$session or the \OC\User\Session will use it \OC::$session = $session; $userSession = new \OC\User\Session($manager, $session); $userSession->setUser($user); }
public function testSetUser() { /** @var ISession | \PHPUnit_Framework_MockObject_MockObject $session */ $session = $this->getMock('\\OC\\Session\\Memory', array(), array('')); $session->expects($this->once())->method('set')->with('user_id', 'foo'); /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $manager */ $manager = $this->getMock('\\OC\\User\\Manager'); $backend = $this->getMock('\\Test\\Util\\User\\Dummy'); /** @var User | \PHPUnit_Framework_MockObject_MockObject $user */ $user = $this->getMock('\\OC\\User\\User', array(), array('foo', $backend)); $user->expects($this->once())->method('getUID')->will($this->returnValue('foo')); $userSession = new \OC\User\Session($manager, $session); $userSession->setUser($user); }