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 {
|
2020-05-18 21:41:31 +00:00
|
|
|
|
2020-06-14 10:51:39 +00:00
|
|
|
protected function setUp() : void {
|
2020-05-18 21:41:31 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
// FIXME: Acknowledge known non-fatal query (T248191)
|
|
|
|
|
$this->setMwGlobals( 'wgDBerrorLog', false );
|
2020-05-29 06:16:51 +00:00
|
|
|
// Deprecations don't matter for what this test cares about. This made browser tests fail
|
|
|
|
|
// on many occasions already. (T236809)
|
|
|
|
|
$this->filterDeprecated( '//' );
|
2020-05-18 21:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-24 14:11:58 +00:00
|
|
|
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 {
|
2019-07-08 12:52:06 +00:00
|
|
|
$executor->executeSpecialPage( $page, '', null, 'qqx', $user );
|
2019-04-19 18:18:22 +00:00
|
|
|
} catch ( \PHPUnit\Framework\Error\Deprecated $deprecated ) {
|
|
|
|
|
// Allow deprecation,
|
|
|
|
|
// this test want to check fatals or other things breaking the extension
|
2019-02-19 20:19:31 +00:00
|
|
|
} catch ( \PHPUnit\Framework\Error\Error $error ) {
|
|
|
|
|
// Let phpunit settings working:
|
|
|
|
|
// - convertErrorsToExceptions="true"
|
|
|
|
|
// - convertNoticesToExceptions="true"
|
|
|
|
|
// - convertWarningsToExceptions="true"
|
|
|
|
|
throw $error;
|
2016-03-24 14:11:58 +00:00
|
|
|
} catch ( Exception $e ) {
|
2019-02-19 20:19:31 +00:00
|
|
|
// Other exceptions are allowed
|
2016-03-24 14:11:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the page fataled phpunit will have already died
|
|
|
|
|
$this->addToAssertionCount( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|