function setUp() { parent::setUp(); // Note this depends on every iteration of the data provider running with a clean parser $this->getEngine()->getParser()->getOptions()->setExpensiveParserFunctionLimit(10); // Some of the tests need this $interpreter = $this->getEngine()->getInterpreter(); $interpreter->callFunction($interpreter->loadString('mw.makeProtectedEnvFuncsForTest = mw.makeProtectedEnvFuncs', 'fortest')); }
protected function setUp() { parent::setUp(); $interpreter = $this->getEngine()->getInterpreter(); $func = $interpreter->wrapPhpFunction(function ($v) { return array(preg_replace('/\\s+/', ' ', trim(var_export($v, 1)))); }); $interpreter->callFunction($interpreter->loadString('mw.var_export = ...', 'fortest'), $func); }
protected function setUp() { global $wgHooks; parent::setUp(); // Hook to inject our interwiki prefix $this->hooks = $wgHooks; $wgHooks['InterwikiLoadPrefix'][] = function ($prefix, &$data) { if ($prefix !== 'scribuntotitletest') { return true; } $data = array('iw_prefix' => 'scribuntotitletest', 'iw_url' => '//test.wikipedia.org/wiki/$1', 'iw_api' => 1, 'iw_wikiid' => 0, 'iw_local' => 0, 'iw_trans' => 0); return false; }; // Page for getContent test $page = WikiPage::factory(Title::newFromText('ScribuntoTestPage')); $page->doEditContent(new WikitextContent('{{int:mainpage}}<includeonly>...</includeonly><noinclude>...</noinclude>'), 'Summary'); // Set restrictions for protectionLevels and cascadingProtection tests // Since mRestrictionsLoaded is true, they don't count as expensive $title = Title::newFromText('Main Page'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array('edit' => array(), 'move' => array()); $title->mCascadeSources = array(Title::makeTitle(NS_MAIN, "Lockbox"), Title::makeTitle(NS_MAIN, "Lockbox2")); $title->mCascadingRestrictions = array('edit' => array('sysop')); $title = Title::newFromText('Module:TestFramework'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array('edit' => array('sysop', 'bogus'), 'move' => array('sysop', 'bogus')); $title->mCascadeSources = array(); $title->mCascadingRestrictions = array(); $title = Title::newFromText('scribuntotitletest:Module:TestFramework'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array(); $title->mCascadeSources = array(); $title->mCascadingRestrictions = array(); $title = Title::newFromText('Talk:Has/A/Subpage'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array('create' => array('sysop')); $title->mCascadeSources = array(); $title->mCascadingRestrictions = array(); $title = Title::newFromText('Not/A/Subpage'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array('edit' => array('autoconfirmed'), 'move' => array('sysop')); $title->mCascadeSources = array(); $title->mCascadingRestrictions = array(); $title = Title::newFromText('Module talk:Test Framework'); $title->mRestrictionsLoaded = true; $title->mRestrictions = array('edit' => array(), 'move' => array('sysop')); $title->mCascadeSources = array(); $title->mCascadingRestrictions = array(); // Note this depends on every iteration of the data provider running with a clean parser $this->getEngine()->getParser()->getOptions()->setExpensiveParserFunctionLimit(10); // Indicate to the tests that it's safe to create the title objects $interpreter = $this->getEngine()->getInterpreter(); $interpreter->callFunction($interpreter->loadString("mw.title.testPageId = {$page->getId()}", 'fortest')); $this->setMwGlobals(array('wgServer' => '//wiki.local', 'wgCanonicalServer' => 'http://wiki.local', 'wgUsePathInfo' => true, 'wgActionPaths' => array(), 'wgScript' => '/w/index.php', 'wgScriptPath' => '/w', 'wgArticlePath' => '/wiki/$1')); }
protected function setUp() { parent::setUp(); // For unstrip test $parser = $this->getEngine()->getParser(); $markers = array('nowiki' => $parser->uniqPrefix() . '-test-nowiki-' . Parser::MARKER_SUFFIX, 'general' => $parser->uniqPrefix() . '-test-general-' . Parser::MARKER_SUFFIX); $parser->mStripState->addNoWiki($markers['nowiki'], 'NoWiki'); $parser->mStripState->addGeneral($markers['general'], 'General'); $interpreter = $this->getEngine()->getInterpreter(); $interpreter->callFunction($interpreter->loadString('mw.text.stripTest = ...', 'fortest'), $markers); }
protected function setUp() { parent::setUp(); // Register libraries for self::testPHPLibrary() $this->mergeMwGlobalArrayValue('wgHooks', array('ScribuntoExternalLibraries' => array(function ($engine, &$libs) { $libs += array('CommonTestsLib' => array('class' => 'Scribunto_LuaCommonTestsLibrary', 'deferLoad' => true), 'CommonTestsFailLib' => array('class' => 'Scribunto_LuaCommonTestsFailLibrary', 'deferLoad' => true)); }))); // Note this depends on every iteration of the data provider running with a clean parser $this->getEngine()->getParser()->getOptions()->setExpensiveParserFunctionLimit(10); // Some of the tests need this $interpreter = $this->getEngine()->getInterpreter(); $interpreter->callFunction($interpreter->loadString('mw.makeProtectedEnvFuncsForTest = mw.makeProtectedEnvFuncs', 'fortest')); }
function setUp() { parent::setUp(); $this->setMwGlobals(array('wgServer' => '//wiki.local', 'wgCanonicalServer' => 'http://wiki.local', 'wgUsePathInfo' => true, 'wgActionPaths' => array(), 'wgScript' => '/w/index.php', 'wgScriptPath' => '/w', 'wgArticlePath' => '/wiki/$1')); }