/** * @dataProvider provideTryNormaliseRedirect * @covers MediaWiki::tryNormaliseRedirect */ public function testTryNormaliseRedirect($url, $query, $title, $expectedRedirect = false) { // Set SERVER because interpolateTitle() doesn't use getRequestURL(), // whereas tryNormaliseRedirect does(). $_SERVER['REQUEST_URI'] = $url; $req = new FauxRequest($query); $req->setRequestURL($url); // This adds a virtual 'title' query parameter. Normally called from Setup.php $req->interpolateTitle(); $titleObj = Title::newFromText($title); // Set global context since some involved code paths don't yet have context $context = RequestContext::getMain(); $context->setRequest($req); $context->setTitle($titleObj); $mw = new MediaWiki($context); $method = new ReflectionMethod($mw, 'tryNormaliseRedirect'); $method->setAccessible(true); $ret = $method->invoke($mw, $titleObj); $this->assertEquals($expectedRedirect !== false, $ret, 'Return true only when redirecting'); $this->assertEquals($expectedRedirect ?: '', $context->getOutput()->getRedirect()); }
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'); }
/** * @covers FauxRequest::setRequestURL * @covers FauxRequest::getRequestURL */ public function testSetRequestURL() { $req = new FauxRequest(); $req->setRequestURL('https://example.org'); $this->assertEquals('https://example.org', $req->getRequestURL()); }