public function loadUserByUsername($username) { $this->session->set('openiduco', 'login'); if ($this->samlAuth->isAuthenticated()) { $user = $this->findUserBySamlId($this->samlAuth->getUsername()); if (!$user) { $this->session->set('openiduco', 'notfound'); throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); } $this->session->set('openiduco', 'found'); return $user; } throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); }
function it_fails_when_user_is_not_authenticated(SamlAuth $auth, UserManagerInterface $userManager) { $username = '******'; $auth->isAuthenticated()->shouldBeCalled()->willReturn(false); $this->shouldThrow(UsernameNotFoundException::class)->duringLoadUserByUsername($username); }