Fix SpecialPageFactory list handling
[lhc/web/wiklou.git] / tests / phpunit / includes / specialpage / SpecialPageFactoryTest.php
index 42602dc..cb12273 100644 (file)
@@ -28,6 +28,25 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                SpecialPageFactory::resetList();
        }
 
+       public function testResetList() {
+               SpecialPageFactory::resetList();
+               $this->assertContains( 'Specialpages', SpecialPageFactory::getNames() );
+       }
+
+       public function testHookNotCalledTwice() {
+               $count = 0;
+               $this->mergeMwGlobalArrayValue( 'wgHooks', array(
+                       'SpecialPage_initList' => array(
+                               function () use ( &$count ) {
+                                       $count++;
+                               }
+               ) ) );
+               SpecialPageFactory::resetList();
+               SpecialPageFactory::getNames();
+               SpecialPageFactory::getNames();
+               $this->assertEquals( 1, $count );
+       }
+
        public function newSpecialAllPages() {
                return new SpecialAllPages();
        }
@@ -235,4 +254,19 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
                );
        }
 
+       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' );
+       }
+
 }