public function loadUserByOAuthUserResponse(UserResponseInterface $response) { try { $user = $this->fosService->loadUserByUsername($response->getUsername()); } catch (UsernameNotFoundException $e) { $user = $this->createNewUser($response->getUsername(), $response->getEmail(), $response); } return $user; }
/** * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException */ public function testLoadUserByInvalidUsername() { $this->userManager->expects($this->once())->method('findUserByUsernameOrEmail')->with('foobar')->will($this->returnValue(null)); $this->userProvider->loadUserByUsername('foobar'); }