/**
  * @param int $userId
  * @return User
  * @throws AuthenticationException
  */
 public function loadUserById($userId)
 {
     $user = $this->userRepository->find($userId);
     if (null === $user) {
         throw new AuthenticationException(sprintf('User with id `%s` not found', $userId));
     }
     return $user;
 }
 /**
  * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
  * @expectedExceptionMessage User with id `1` not found
  */
 public function testLoadUserByIdThrowsExceptionWhenNoUserWithGivenId()
 {
     $this->userRepository->find(1)->willReturn(null);
     $this->apiKeyUserProvider->loadUserById(1);
 }