LocalisationCache: try harder to use LCStoreCDB
[lhc/web/wiklou.git] / tests / phpunit / includes / specialpage / SpecialPageFactoryTest.php
index 4619c2e..fd6911f 100644 (file)
@@ -28,17 +28,47 @@ 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();
        }
 
        public function specialPageProvider() {
+               $specialPageTestHelper = new SpecialPageTestHelper();
+
                return array(
                        'class name' => array( 'SpecialAllPages', false ),
-                       'closure' => array( function() {
+                       'closure' => array( function () {
                                return new SpecialAllPages();
                        }, false ),
-                       'function' => array( array( $this, 'newSpecialAllPages' ), false  ),
+                       'function' => array( array( $this, 'newSpecialAllPages' ), false ),
+                       'callback string' => array( 'SpecialPageTestHelper::newSpecialAllPages', false ),
+                       'callback with object' => array(
+                               array( $specialPageTestHelper, 'newSpecialAllPages' ),
+                               false
+                       ),
+                       'callback array' => array(
+                               array( 'SpecialPageTestHelper', 'newSpecialAllPages' ),
+                               false
+                       )
                );
        }
 
@@ -235,4 +265,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' );
+       }
+
 }