function testShouldGet10FirstUsers()
 {
     $config = readConfiguration('test/config.yml');
     $token = \UserVoice\SSO::generate_token($config['subdomain_name'], $config['sso_key'], array('email' => '*****@*****.**'));
     // Try it out here:
     // echo $config['protocol'] . '://' . $config['subdomain_name'] . '.' . $config['uservoice_domain'] . '?sso='.$token;
     $this->assertTrue(strlen($token) > 0);
 }
 public static function generateSso(ContainerInterface $container, $displayName)
 {
     // https://developer.uservoice.com/docs/single-sign-on/single-sign-on/
     $supportedLocales = array('ar', 'bg', 'cn', 'cz', 'da', 'de', 'en', 'es', 'et', 'fi', 'fr', 'fr-CA', 'he', 'hr', 'it', 'ja', 'lv', 'nl', 'no_NB', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'sk', 'sl', 'sr', 'sr-Latn', 'sv-SE', 'tr', 'zh-TW');
     // Deduce the best locale according to UserVoice constraints
     $currentLocale = $container->get('request')->getLocale();
     $locale = Locale::lookup($supportedLocales, $currentLocale, true, 'en');
     // Read configuration
     $domain = UserVoiceHelper::getParameter($container, 'domain');
     $ssoKey = UserVoiceHelper::getParameter($container, 'sso_key');
     if (!$ssoKey || !$domain) {
         return null;
     }
     // Assume the user_id is email based
     $user = UserVoiceHelper::getUser($container);
     if (!$user) {
         return null;
     }
     $userId = $user->getUsername();
     $ssoToken = SSO::generate_token($domain, $ssoKey, array('guid' => $userId, 'display_name' => $displayName, 'email' => $userId, 'locale' => $locale));
     return $ssoToken;
 }