public function tearDown() { foreach ($this->unsetReqVals as $v) { MobileContext::singleton()->getRequest()->unsetVal($v); } MobileContext::setInstance(null); // refresh MobileContext instance parent::tearDown(); }
public function testBug71329() { SpecialPageFactory::resetList(); RequestContext::resetMain(); $req = new FauxRequest(array('title' => 'Special:Search', 'mobileaction' => 'toggle_view_mobile')); $req->setRequestURL('/w/index.php?title=Special:Search&mobileaction=toggle_view_mobile'); RequestContext::getMain()->setRequest($req); MobileContext::setInstance(null); $this->setMwGlobals('wgTitle', null); SpecialPage::getTitleFor('Search'); $this->assertTrue(true, 'In case of failure this test just crashes'); }
/** * Creates a new set of object for the actual test context, including a new * outputpage and skintemplate. * * @param string $mode The mode for the test cases (desktop, mobile) * @return array Array of objects, including MobileContext (context), * SkinTemplate (sk) and OutputPage (out) */ protected function getContextSetup($mode, $mfXAnalyticsItems) { // Create a new MobileContext object for this test MobileContext::setInstance(null); // create a new instance of MobileContext $context = MobileContext::singleton(); // create a DerivativeContext to use in MobileContext later $mainContext = new DerivativeContext(RequestContext::getMain()); // create a new, empty OutputPage $out = new OutputPage($context); // create a new, empty SkinTemplate $sk = new SkinTemplate(); // create a new Title (main page) $title = Title::newMainPage(); // create a FauxRequest to use instead of a WebRequest object (FauxRequest forces // the creation of a FauxResponse, which allows to investigate sent header values) $request = new FauxRequest(); // set the new request object to the context $mainContext->setRequest($request); // set the main page title to the context $mainContext->setTitle($title); // set the context to the SkinTemplate $sk->setContext($mainContext); // set the OutputPage to the context $mainContext->setOutput($out); // set the DerivativeContext as a base to MobileContext $context->setContext($mainContext); // set the mode to MobileContext $context->setUseFormat($mode); // if there are any XAnalytics items, add them foreach ($mfXAnalyticsItems as $key => $val) { $context->addAnalyticsLogItem($key, $val); } // set the newly created MobileContext object as the current instance to use MobileContext::setInstance($context); // return the stuff return array('out' => $out, 'sk' => $sk, 'context' => $context); }
public function testOnTitleSquidURLs() { $this->setMwGlobals(array('wgMobileUrlTemplate' => '%h0.m.%h1.%h2', 'wgServer' => 'http://en.wikipedia.org', 'wgArticlePath' => '/wiki/$1', 'wgScriptPath' => '/w', 'wgScript' => '/w/index.php')); MobileContext::setInstance(null); $title = Title::newFromText('PurgeTest'); $urls = $title->getCdnUrls(); $expected = array('http://en.wikipedia.org/wiki/PurgeTest', 'http://en.wikipedia.org/w/index.php?title=PurgeTest&action=history', 'http://en.m.wikipedia.org/w/index.php?title=PurgeTest&action=history', 'http://en.m.wikipedia.org/wiki/PurgeTest'); $this->assertArrayEquals($expected, $urls); }