2016-03-24 14:11:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
2018-08-12 09:08:58 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2016-03-24 14:11:58 +00:00
|
|
|
/**
|
|
|
|
|
* Test that runs against all registered special pages to make sure that regular
|
|
|
|
|
* execution of the special page does not cause a fatal error.
|
|
|
|
|
*
|
|
|
|
|
* UTSysop is used to run as much of the special page code as possible without
|
|
|
|
|
* actually knowing the details of the special page.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.32
|
|
|
|
|
* @author Addshore
|
|
|
|
|
*/
|
|
|
|
|
class SpecialPageFatalTest extends MediaWikiTestCase {
|
|
|
|
|
public function provideSpecialPages() {
|
|
|
|
|
$specialPages = [];
|
2018-08-12 09:08:58 +00:00
|
|
|
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
|
|
|
|
|
foreach ( $spf->getNames() as $name ) {
|
|
|
|
|
$specialPages[$name] = [ $spf->getPage( $name ) ];
|
2016-03-24 14:11:58 +00:00
|
|
|
}
|
|
|
|
|
return $specialPages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideSpecialPages
|
|
|
|
|
*/
|
|
|
|
|
public function testSpecialPageDoesNotFatal( SpecialPage $page ) {
|
|
|
|
|
$executor = new SpecialPageExecutor();
|
|
|
|
|
$user = User::newFromName( 'UTSysop' );
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$executor->executeSpecialPage( $page, '', null, null, $user );
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
// Exceptions are allowed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the page fataled phpunit will have already died
|
|
|
|
|
$this->addToAssertionCount( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|