/**
  * @dataProvider formatProvider
  */
 public function testFormat(array $expectedTags, array $patterns, RecentChange $recentChange)
 {
     $context = $this->getTestContext();
     // Use the actual setting, because out handler for the FormatAutocomment hook will check
     // the wiki id against this setting.
     $repoWikiId = WikibaseClient::getDefaultInstance()->getSettings()->getSetting('repoSiteId');
     $changesList = ChangesList::newFromContext($context);
     $changeFactory = new ExternalChangeFactory($repoWikiId, Language::factory('en'));
     $externalChange = $changeFactory->newFromRecentChange($recentChange);
     $formatter = new ChangeLineFormatter($changesList->getUser(), Language::factory('en'), $this->repoLinker);
     $formattedLine = $formatter->format($externalChange, $recentChange->getTitle(), $recentChange->counter, $changesList->recentChangesFlags(array('wikibase-edit' => true), ''));
     foreach ($expectedTags as $key => $tag) {
         $this->assertTag($tag, $formattedLine, $key . "\n\t" . $formattedLine);
     }
     foreach ($patterns as $pattern) {
         $this->assertRegExp($pattern, $formattedLine);
     }
 }
 /**
  * Hook for formatting recent changes linkes
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/OldChangesListRecentChangesLine
  *
  * @since 0.2
  *
  * @param ChangesList $changesList
  * @param string $s
  * @param RecentChange $rc
  * @param string[] &$classes
  *
  * @return bool
  */
 public static function onOldChangesListRecentChangesLine(ChangesList &$changesList, &$s, RecentChange $rc, &$classes = array())
 {
     $type = $rc->getAttribute('rc_type');
     if ($type == RC_EXTERNAL) {
         $wikibaseClient = WikibaseClient::getDefaultInstance();
         $changeFactory = new ExternalChangeFactory($wikibaseClient->getSettings()->getSetting('repoSiteId'), $wikibaseClient->getContentLanguage());
         try {
             $externalChange = $changeFactory->newFromRecentChange($rc);
         } catch (UnexpectedValueException $ex) {
             // @fixme use rc_source column to better distinguish
             // Wikibase changes vs. non-wikibase, and unexpected
             // stuff in Wikibase changes.
             wfWarn('Invalid or not a Wikibase change.');
             return false;
         }
         // fixme: inject formatter and flags into a changes list formatter
         $formatter = new ChangeLineFormatter($changesList->getUser(), $changesList->getLanguage(), $wikibaseClient->newRepoLinker());
         $flag = $changesList->recentChangesFlags(array('wikibase-edit' => true), '');
         $line = $formatter->format($externalChange, $rc->getTitle(), $rc->counter, $flag);
         $classes[] = 'wikibase-edit';
         $s = $line;
     }
     // OutputPage will ignore multiple calls
     $changesList->getOutput()->addModuleStyles('wikibase.client.changeslist.css');
     return true;
 }