protected function setUp() { global $wgNamespaceAliases, $wgContLang; global $wgHooks, $IP; parent::setUp(); // Setup CLI arguments if ($this->getCliArg('regex')) { $this->regex = $this->getCliArg('regex'); } else { # Matches anything $this->regex = ''; } $this->keepUploads = $this->getCliArg('keep-uploads'); $tmpGlobals = []; $tmpGlobals['wgLanguageCode'] = 'en'; $tmpGlobals['wgContLang'] = Language::factory('en'); $tmpGlobals['wgSitename'] = 'MediaWiki'; $tmpGlobals['wgServer'] = 'http://example.org'; $tmpGlobals['wgServerName'] = 'example.org'; $tmpGlobals['wgScriptPath'] = ''; $tmpGlobals['wgScript'] = '/index.php'; $tmpGlobals['wgResourceBasePath'] = ''; $tmpGlobals['wgStylePath'] = '/skins'; $tmpGlobals['wgExtensionAssetsPath'] = '/extensions'; $tmpGlobals['wgArticlePath'] = '/wiki/$1'; $tmpGlobals['wgActionPaths'] = []; $tmpGlobals['wgVariantArticlePath'] = false; $tmpGlobals['wgEnableUploads'] = true; $tmpGlobals['wgUploadNavigationUrl'] = false; $tmpGlobals['wgThumbnailScriptPath'] = false; $tmpGlobals['wgLocalFileRepo'] = ['class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => 'local-backend']; $tmpGlobals['wgForeignFileRepos'] = []; $tmpGlobals['wgDefaultExternalStore'] = []; $tmpGlobals['wgParserCacheType'] = CACHE_NONE; $tmpGlobals['wgCapitalLinks'] = true; $tmpGlobals['wgNoFollowLinks'] = true; $tmpGlobals['wgNoFollowDomainExceptions'] = []; $tmpGlobals['wgExternalLinkTarget'] = false; $tmpGlobals['wgThumbnailScriptPath'] = false; $tmpGlobals['wgUseImageResize'] = true; $tmpGlobals['wgAllowExternalImages'] = true; $tmpGlobals['wgRawHtml'] = false; $tmpGlobals['wgExperimentalHtmlIds'] = false; $tmpGlobals['wgAdaptiveMessageCache'] = true; $tmpGlobals['wgUseDatabaseMessages'] = true; $tmpGlobals['wgLocaltimezone'] = 'UTC'; $tmpGlobals['wgGroupPermissions'] = ['*' => ['createaccount' => true, 'read' => true, 'edit' => true, 'createpage' => true, 'createtalk' => true]]; $tmpGlobals['wgNamespaceProtection'] = [NS_MEDIAWIKI => 'editinterface']; $tmpGlobals['wgParser'] = new StubObject('wgParser', $GLOBALS['wgParserConf']['class'], [$GLOBALS['wgParserConf']]); $tmpGlobals['wgFileExtensions'][] = 'svg'; $tmpGlobals['wgSVGConverter'] = 'rsvg'; $tmpGlobals['wgSVGConverters']['rsvg'] = '$path/rsvg-convert -w $width -h $height -o $output $input'; if ($GLOBALS['wgStyleDirectory'] === false) { $tmpGlobals['wgStyleDirectory'] = "{$IP}/skins"; } # Replace all media handlers with a mock. We do not need to generate # actual thumbnails to do parser testing, we only care about receiving # a ThumbnailImage properly initialized. global $wgMediaHandlers; foreach ($wgMediaHandlers as $type => $handler) { $tmpGlobals['wgMediaHandlers'][$type] = 'MockBitmapHandler'; } // Vector images have to be handled slightly differently $tmpGlobals['wgMediaHandlers']['image/svg+xml'] = 'MockSvgHandler'; // DjVu images have to be handled slightly differently $tmpGlobals['wgMediaHandlers']['image/vnd.djvu'] = 'MockDjVuHandler'; // Ogg video/audio increasingly more differently $tmpGlobals['wgMediaHandlers']['application/ogg'] = 'MockOggHandler'; $tmpHooks = $wgHooks; $tmpHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; $tmpHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; $tmpGlobals['wgHooks'] = $tmpHooks; # add a namespace shadowing a interwiki link, to test # proper precedence when resolving links. (bug 51680) $tmpGlobals['wgExtraNamespaces'] = [100 => 'MemoryAlpha', 101 => 'MemoryAlpha_talk']; $tmpGlobals['wgLocalInterwikis'] = ['local', 'mi']; # "extra language links" # see https://gerrit.wikimedia.org/r/111390 $tmpGlobals['wgExtraInterlanguageLinkPrefixes'] = ['mul']; // DjVu support $this->djVuSupport = new DjVuSupport(); // Tidy support $this->tidySupport = new TidySupport(); $tmpGlobals['wgTidyConfig'] = null; $tmpGlobals['wgUseTidy'] = false; $tmpGlobals['wgDebugTidy'] = false; $tmpGlobals['wgTidyConf'] = $IP . '/includes/tidy/tidy.conf'; $tmpGlobals['wgTidyOpts'] = ''; $tmpGlobals['wgTidyInternal'] = $this->tidySupport->isInternal(); $this->setMwGlobals($tmpGlobals); $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image']; $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk']; $wgNamespaceAliases['Image'] = NS_FILE; $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; MWNamespace::getCanonicalNamespaces(true); # reset namespace cache $wgContLang->resetNamespaces(); # reset namespace cache ParserTest::resetTitleServices(); }