MediaWiki
REL1_24
|
00001 <?php 00023 class SpecialPageFactoryTest extends MediaWikiTestCase { 00024 00025 public function newSpecialAllPages() { 00026 return new SpecialAllPages(); 00027 } 00028 00029 public function specialPageProvider() { 00030 return array( 00031 'class name' => array( 'SpecialAllPages', false ), 00032 'closure' => array( function() { 00033 return new SpecialAllPages(); 00034 }, false ), 00035 'function' => array( array( $this, 'newSpecialAllPages' ), false ), 00036 ); 00037 } 00038 00042 public function testGetPage( $spec, $shouldReuseInstance ) { 00043 $this->mergeMwGlobalArrayValue( 'wgSpecialPages', array( 'testdummy' => $spec ) ); 00044 00045 SpecialPageFactory::resetList(); 00046 00047 $page = SpecialPageFactory::getPage( 'testdummy' ); 00048 $this->assertInstanceOf( 'SpecialPage', $page ); 00049 00050 $page2 = SpecialPageFactory::getPage( 'testdummy' ); 00051 $this->assertEquals( $shouldReuseInstance, $page2 === $page, "Should re-use instance:" ); 00052 00053 SpecialPageFactory::resetList(); 00054 } 00055 00056 public function testGetNames() { 00057 $this->mergeMwGlobalArrayValue( 'wgSpecialPages', array( 'testdummy' => 'SpecialAllPages' ) ); 00058 00059 SpecialPageFactory::resetList(); 00060 $names = SpecialPageFactory::getNames(); 00061 $this->assertInternalType( 'array', $names ); 00062 $this->assertContains( 'testdummy', $names ); 00063 SpecialPageFactory::resetList(); 00064 } 00065 00066 public function testResolveAlias() { 00067 $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) ); 00068 00069 SpecialPageFactory::resetList(); 00070 00071 list( $name, $param ) = SpecialPageFactory::resolveAlias( 'Spezialseiten/Foo' ); 00072 $this->assertEquals( 'Specialpages', $name ); 00073 $this->assertEquals( 'Foo', $param ); 00074 00075 SpecialPageFactory::resetList(); 00076 } 00077 00078 public function testGetLocalNameFor() { 00079 $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) ); 00080 00081 SpecialPageFactory::resetList(); 00082 00083 $name = SpecialPageFactory::getLocalNameFor( 'Specialpages', 'Foo' ); 00084 $this->assertEquals( 'Spezialseiten/Foo', $name ); 00085 00086 SpecialPageFactory::resetList(); 00087 } 00088 00089 public function testGetTitleForAlias() { 00090 $this->setMwGlobals( 'wgContLang', Language::factory( 'de' ) ); 00091 00092 SpecialPageFactory::resetList(); 00093 00094 $title = SpecialPageFactory::getTitleForAlias( 'Specialpages/Foo' ); 00095 $this->assertEquals( 'Spezialseiten/Foo', $title->getText() ); 00096 $this->assertEquals( NS_SPECIAL, $title->getNamespace() ); 00097 00098 SpecialPageFactory::resetList(); 00099 } 00100 00101 }