public function testGetAliasListRecursion()
 {
     $called = false;
     $this->mergeMwGlobalArrayValue('wgHooks', array('SpecialPage_initList' => array(function () use(&$called) {
         SpecialPageFactory::getLocalNameFor('Specialpages');
         $called = true;
     })));
     SpecialPageFactory::resetList();
     SpecialPageFactory::getLocalNameFor('Specialpages');
     $this->assertTrue($called, 'Recursive call succeeded');
 }
 /**
  * @dataProvider provideTestConflictResolution
  */
 public function testConflictResolution($test, $aliasesList, $alias, $expectedName, $expectedAlias, $expectWarnings)
 {
     global $wgContLang;
     $lang = clone $wgContLang;
     $lang->mExtendedSpecialPageAliases = $aliasesList;
     $this->setMwGlobals('wgContLang', $lang);
     $this->setMwGlobals('wgSpecialPages', array_combine(array_keys($aliasesList), array_keys($aliasesList)));
     SpecialPageFactory::resetList();
     // Catch the warnings we expect to be raised
     $warnings = array();
     $this->setMwGlobals('wgDevelopmentWarnings', true);
     set_error_handler(function ($errno, $errstr) use(&$warnings) {
         if (preg_match('/First alias \'[^\']*\' for .*/', $errstr) || preg_match('/Did not find a usable alias for special page .*/', $errstr)) {
             $warnings[] = $errstr;
             return true;
         }
         return false;
     });
     $reset = new ScopedCallback('restore_error_handler');
     list($name, ) = SpecialPageFactory::resolveAlias($alias);
     $this->assertEquals($expectedName, $name, "{$test}: Alias to name");
     $result = SpecialPageFactory::getLocalNameFor($name);
     $this->assertEquals($expectedAlias, $result, "{$test}: Alias to name to alias");
     $gotWarnings = count($warnings);
     if ($gotWarnings !== $expectWarnings) {
         $this->fail("Expected {$expectWarnings} warning(s), but got {$gotWarnings}:\n" . join("\n", $warnings));
     }
 }
 public function tearDown()
 {
     parent::tearDown();
     TestingAccessWrapper::newFromClass('Hooks')->handlers = $this->originalHandlers;
     SpecialPageFactory::resetList();
 }
 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');
 }