summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:02 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:02 -0400
commit1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch)
treef1fdd326034e05177596851be6a7127615d81498 /tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
parent9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff)
parentf6d65e533c62f6deb21342d4901ece24497b433e (diff)
Merge commit 'f6d65'
# Conflicts: # skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php')
-rw-r--r--tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php62
1 files changed, 60 insertions, 2 deletions
diff --git a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
index 779fa558..fd6911f6 100644
--- a/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
+++ b/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
@@ -28,21 +28,52 @@ 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
+ )
);
}
/**
+ * @covers SpecialPageFactory::getPage
* @dataProvider specialPageProvider
*/
public function testGetPage( $spec, $shouldReuseInstance ) {
@@ -56,6 +87,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
$this->assertEquals( $shouldReuseInstance, $page2 === $page, "Should re-use instance:" );
}
+ /**
+ * @covers SpecialPageFactory::getNames
+ */
public function testGetNames() {
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', array( 'testdummy' => 'SpecialAllPages' ) );
SpecialPageFactory::resetList();
@@ -65,6 +99,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
$this->assertContains( 'testdummy', $names );
}
+ /**
+ * @covers SpecialPageFactory::resolveAlias
+ */
public function testResolveAlias() {
$this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );
SpecialPageFactory::resetList();
@@ -74,6 +111,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
$this->assertEquals( 'Foo', $param );
}
+ /**
+ * @covers SpecialPageFactory::getLocalNameFor
+ */
public function testGetLocalNameFor() {
$this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );
SpecialPageFactory::resetList();
@@ -82,6 +122,9 @@ class SpecialPageFactoryTest extends MediaWikiTestCase {
$this->assertEquals( 'Spezialseiten/Foo', $name );
}
+ /**
+ * @covers SpecialPageFactory::getTitleForAlias
+ */
public function testGetTitleForAlias() {
$this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) );
SpecialPageFactory::resetList();
@@ -222,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' );
+ }
+
}