summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
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' );
+ }
+
}