function setUp() { global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath; $wgScript = '/index.php'; $wgScriptPath = '/'; $wgArticlePath = '/wiki/$1'; $wgStyleSheetPath = '/skins'; $wgStylePath = '/skins'; $wgThumbnailScriptPath = false; $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => wfTempDir() . '/test-repo', 'url' => 'http://example.com/images', 'deletedDir' => wfTempDir() . '/test-repo/delete', 'hashLevels' => 2, 'transformVia404' => false); $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; $wgNamespaceAliases['Image'] = NS_FILE; $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; $wgEnableParserCache = false; $wgDeferredUpdateList = array(); $wgMemc = wfGetMainCache(); $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); // $wgContLang = new StubContLang; $wgUser = new User(); $context = new RequestContext(); $wgLang = $context->getLang(); $wgOut = $context->getOutput(); $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf)); $wgRequest = new WebRequest(); if ($wgStyleDirectory === false) { $wgStyleDirectory = "{$IP}/skins"; } }
/** * Set up the global variables for a consistent environment for each test. * Ideally this should replace the global configuration entirely. */ protected function setupGlobals($opts = '', $config = '') { # Find out values for some special options. $lang = self::getOptionValue('language', $opts, 'en'); $variant = self::getOptionValue('variant', $opts, false); $maxtoclevel = self::getOptionValue('wgMaxTocLevel', $opts, 999); $linkHolderBatchSize = self::getOptionValue('wgLinkHolderBatchSize', $opts, 1000); $settings = array('wgServer' => 'http://Britney-Spears', 'wgScript' => '/index.php', 'wgScriptPath' => '/', 'wgArticlePath' => '/wiki/$1', 'wgActionPaths' => array(), 'wgLocalFileRepo' => array('class' => 'LocalRepo', 'name' => 'local', 'directory' => $this->uploadDir, 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false), 'wgEnableUploads' => self::getOptionValue('wgEnableUploads', $opts, true), 'wgStylePath' => '/skins', 'wgStyleSheetPath' => '/skins', 'wgSitename' => 'MediaWiki', 'wgLanguageCode' => $lang, 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_', 'wgRawHtml' => isset($opts['rawhtml']), 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array(0 => isset($opts['subpage'])), 'wgMaxTocLevel' => $maxtoclevel, 'wgCapitalLinks' => true, 'wgNoFollowLinks' => true, 'wgNoFollowDomainExceptions' => array(), 'wgThumbnailScriptPath' => false, 'wgUseImageResize' => false, 'wgUseTeX' => isset($opts['math']), 'wgMathDirectory' => $this->uploadDir . '/math', 'wgLocaltimezone' => 'UTC', 'wgAllowExternalImages' => true, 'wgUseTidy' => false, 'wgDefaultLanguageVariant' => $variant, 'wgVariantArticlePath' => false, 'wgGroupPermissions' => array('*' => array('createaccount' => true, 'read' => true, 'edit' => true, 'createpage' => true, 'createtalk' => true)), 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface'), 'wgDefaultExternalStore' => array(), 'wgForeignFileRepos' => array(), 'wgLinkHolderBatchSize' => $linkHolderBatchSize, 'wgExperimentalHtmlIds' => false, 'wgExternalLinkTarget' => false, 'wgAlwaysUseTidy' => false, 'wgHtml5' => true, 'wgWellFormedXml' => true, 'wgAllowMicrodataAttributes' => true, 'wgAdaptiveMessageCache' => true, 'wgUseDatabaseMessages' => true); if ($config) { $configLines = explode("\n", $config); foreach ($configLines as $line) { list($var, $value) = explode('=', $line, 2); $settings[$var] = eval("return {$value};"); //??? } } $this->savedGlobals = array(); foreach ($settings as $var => $val) { if (array_key_exists($var, $GLOBALS)) { $this->savedGlobals[$var] = $GLOBALS[$var]; } $GLOBALS[$var] = $val; } $langObj = Language::factory($lang); $GLOBALS['wgContLang'] = $langObj; $context = new RequestContext(); $GLOBALS['wgLang'] = $context->getLang(); $GLOBALS['wgMemc'] = new EmptyBagOStuff(); $GLOBALS['wgOut'] = $context->getOutput(); global $wgHooks; $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup'; $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; MagicWord::clearCache(); # Publish the articles after we have the final language set $this->publishTestArticles(); # The entries saved into RepoGroup cache with previous globals will be wrong. RepoGroup::destroySingleton(); MessageCache::singleton()->destroyInstance(); global $wgUser; $wgUser = new User(); }