/**
  * @dataProvider getLinksProvider
  */
 public function testGetLinks($expected, $title, $action, $noExternalLangLinks, $prefixedId, $hasLangLinks)
 {
     $repoLinker = $this->getRepoLinker();
     $namespaceChecker = $this->getNamespaceChecker();
     $entityIdParser = $this->getEntityIdParser();
     $repoItemLinkGenerator = new RepoItemLinkGenerator($namespaceChecker, $repoLinker, $entityIdParser, 'wikipedia', 'enwiki');
     $link = $repoItemLinkGenerator->getLink($title, $action, $hasLangLinks, $noExternalLangLinks, $prefixedId);
     if ($expected === null) {
         $this->assertNull($link);
     } else {
         $this->assertRegexp($expected, $link);
     }
 }
 /**
  * Displays a list of links to pages on the central wiki at the end of the language box.
  *
  * @since 0.1
  *
  * @param Skin $skin
  * @param QuickTemplate $template
  *
  * @return bool
  */
 public static function onSkinTemplateOutputPageBeforeExec(Skin &$skin, QuickTemplate &$template)
 {
     $title = $skin->getContext()->getTitle();
     $wikibaseClient = WikibaseClient::getDefaultInstance();
     if (!self::isWikibaseEnabled($title->getNamespace())) {
         // shorten out
         return true;
     }
     $repoLinker = $wikibaseClient->newRepoLinker();
     $entityIdParser = $wikibaseClient->getEntityIdParser();
     $siteGroup = $wikibaseClient->getLangLinkSiteGroup();
     $languageUrls = $template->get('language_urls');
     $hasLangLinks = $languageUrls !== false && !empty($languageUrls);
     $langLinkGenerator = new RepoItemLinkGenerator(WikibaseClient::getDefaultInstance()->getNamespaceChecker(), $repoLinker, $entityIdParser, $siteGroup, $wikibaseClient->getSettings()->getSetting('siteGlobalID'));
     $action = Action::getActionName($skin->getContext());
     $noExternalLangLinks = $skin->getOutput()->getProperty('noexternallanglinks');
     $prefixedId = $skin->getOutput()->getProperty('wikibase_item');
     $editLink = $langLinkGenerator->getLink($title, $action, $hasLangLinks, $noExternalLangLinks, $prefixedId);
     // there will be no link in some situations, like add links widget disabled
     if ($editLink) {
         $template->set('wbeditlanglinks', $editLink);
     }
     // Needed to have "Other languages" section display, so we can add "add links".
     // Only force the section to display if we are going to actually add such a link:
     // Where external langlinks aren't suppressed and where action == 'view'.
     if ($languageUrls === false && $title->exists() && ($noExternalLangLinks === null || !in_array('*', $noExternalLangLinks)) && $action === 'view') {
         $template->set('language_urls', array());
     }
     return true;
 }