* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @covers SpecialPageFactory
+ * @covers \MediaWiki\Special\SpecialPageFactory
* @group SpecialPage
*/
class SpecialPageFactoryTest extends MediaWikiTestCase {
-
- protected function tearDown() {
- parent::tearDown();
-
- SpecialPageFactory::resetList();
- }
-
- public function testResetList() {
- SpecialPageFactory::resetList();
- $this->assertContains( 'Specialpages', SpecialPageFactory::getNames() );
- }
-
public function testHookNotCalledTwice() {
$count = 0;
$this->mergeMwGlobalArrayValue( 'wgHooks', [
$count++;
}
] ] );
- SpecialPageFactory::resetList();
- SpecialPageFactory::getNames();
- SpecialPageFactory::getNames();
+ $this->overrideMwServices();
+ $spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
+ $spf->getNames();
+ $spf->getNames();
$this->assertEquals( 1, $count );
}
*/
public function testGetPage( $spec, $shouldReuseInstance ) {
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => $spec ] );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
$page = SpecialPageFactory::getPage( 'testdummy' );
$this->assertInstanceOf( SpecialPage::class, $page );
*/
public function testGetNames() {
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => SpecialAllPages::class ] );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
$names = SpecialPageFactory::getNames();
$this->assertInternalType( 'array', $names );
*/
public function testResolveAlias() {
$this->setContentLang( 'de' );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
list( $name, $param ) = SpecialPageFactory::resolveAlias( 'Spezialseiten/Foo' );
$this->assertEquals( 'Specialpages', $name );
*/
public function testGetLocalNameFor() {
$this->setContentLang( 'de' );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
$name = SpecialPageFactory::getLocalNameFor( 'Specialpages', 'Foo' );
$this->assertEquals( 'Spezialseiten/Foo', $name );
*/
public function testGetTitleForAlias() {
$this->setContentLang( 'de' );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
$title = SpecialPageFactory::getTitleForAlias( 'Specialpages/Foo' );
$this->assertEquals( 'Spezialseiten/Foo', $title->getText() );
) {
$lang = clone MediaWikiServices::getInstance()->getContentLanguage();
$lang->mExtendedSpecialPageAliases = $aliasesList;
- $this->setContentLang( $lang );
$this->setMwGlobals( 'wgSpecialPages',
array_combine( array_keys( $aliasesList ), array_keys( $aliasesList ) )
);
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
+ $this->setContentLang( $lang );
// Catch the warnings we expect to be raised
$warnings = [];
}
],
] );
- SpecialPageFactory::resetList();
+ $this->overrideMwServices();
SpecialPageFactory::getLocalNameFor( 'Specialpages' );
$this->assertTrue( $called, 'Recursive call succeeded' );
}