public function testGetIframeURL()
 {
     $uri = UrlGenerator::getIframeURL($this->gadget, $this->context);
     $query = parse_url($uri, PHP_URL_QUERY);
     $query = explode('&', $query);
     $args = array();
     foreach ($query as $param) {
         $param = explode('=', $param);
         list($key, $value) = $param;
         $args[$key] = $value ? $value : '';
     }
     $this->assertArrayHasKey('container', $args);
     $this->assertArrayHasKey('lang', $args);
     $this->assertArrayHasKey('country', $args);
     $this->assertArrayHasKey('view', $args);
     $this->assertArrayHasKey('url', $args);
 }
 private function makeResponse($gadget, $gadgetModuleId, $gadgetUrl, $context)
 {
     $response = array();
     $prefs = array();
     foreach ($gadget->getUserPrefs() as $pref) {
         $prefs[$pref->getName()] = array('displayName' => $pref->getDisplayName(), 'type' => $pref->getDataType(), 'default' => $pref->getDefaultValue(), 'enumValues' => $pref->getEnumValues(), 'required' => $pref->isRequired());
     }
     $features = array();
     foreach ($gadget->getRequires() as $feature) {
         $features[] = $feature->getName();
     }
     $views = array();
     foreach ($gadget->getViews() as $view) {
         // we want to include all information, except for the content
         unset($view->content);
         $views[$view->getName()] = $view;
     }
     $links = array();
     foreach ($gadget->links as $link) {
         $links[] = $link;
     }
     $icons = array();
     foreach ($gadget->getIcons() as $icon) {
         $icons[] = $icon;
     }
     $oauth = array();
     $oauthspec = $gadget->getOAuthSpec();
     if (!empty($oauthspec)) {
         foreach ($oauthspec->getServices() as $oauthservice) {
             $oauth[$oauthservice->getName()] = array("request" => $oauthservice->getRequestUrl(), "access" => $oauthservice->getAccessUrl(), "authorization" => $oauthservice->getAuthorizationUrl());
         }
     }
     $response['author'] = $gadget->getAuthor();
     $response['authorEmail'] = $gadget->getAuthorEmail();
     $response['description'] = $gadget->getDescription();
     $response['directoryTitle'] = $gadget->getDirectoryTitle();
     $response['features'] = $features;
     $response['screenshot'] = $gadget->getScreenShot();
     $response['thumbnail'] = $gadget->getThumbnail();
     $response['title'] = $gadget->getTitle();
     $response['titleUrl'] = $gadget->getTitleUrl();
     $response['authorAffiliation'] = $gadget->getAuthorAffiliation();
     $response['authorLocation'] = $gadget->getAuthorLocation();
     $response['authorPhoto'] = $gadget->getAuthorPhoto();
     $response['authorAboutme'] = $gadget->getAuthorAboutme();
     $response['authorQuote'] = $gadget->getAuthorQuote();
     $response['authorLink'] = $gadget->getAuthorLink();
     $response['showInDirectory'] = $gadget->getShowInDirectory();
     $response['showStats'] = $gadget->getShowStats();
     $response['width'] = $gadget->getWidth();
     $response['height'] = $gadget->getHeight();
     $response['categories'] = array($gadget->getCategory(), $gadget->getCategory2());
     $response['singleton'] = $gadget->getSingleton();
     $response['scaling'] = $gadget->getScaling();
     $response['scrolling'] = $gadget->getScrolling();
     $response['links'] = $links;
     $response['views'] = $views;
     $response['icons'] = $icons;
     $response['moduleId'] = $gadgetModuleId;
     $response['url'] = $gadgetUrl;
     $response['iframeUrl'] = UrlGenerator::getIframeURL($gadget, $context);
     $response['userPrefs'] = $prefs;
     $response['oauth'] = $oauth;
     return $response;
 }