public function testGetUser() { $username = '******'; $user = new User(); $this->getMockUserResource()->expects($this->once())->method('getUserByUsername')->with($username)->will($this->returnValue($user)); $this->assertSame($user, $this->crowd->getUser($username)); }
/** * @param string $username The username * * @return UserInterface * * @see UsernameNotFoundException * * @throws UsernameNotFoundException if the user is not found * */ public function loadUserByUsername($username) { $sessionKey = 'seiffert_crowd_auth.user'; if ($this->session->has($sessionKey)) { return $this->session->get($sessionKey); } try { $user = User::fromUser($this->crowd->getUser($username)); $this->session->set($sessionKey, $user); return $user; } catch (UserNotFoundException $e) { throw new UsernameNotFoundException($e->getMessage(), $e->getCode(), $e); } }