2016-03-24 14:11:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
2018-08-12 09:08:58 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2021-01-08 02:27:02 +00:00
|
|
|
use MediaWiki\Permissions\UltimateAuthority;
|
|
|
|
|
use MediaWiki\User\UserIdentityValue;
|
2018-08-12 09:08:58 +00:00
|
|
|
|
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
|
2022-10-07 00:45:44 +00:00
|
|
|
* @coversNothing
|
2016-03-24 14:11:58 +00:00
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class SpecialPageFatalTest extends MediaWikiIntegrationTestCase {
|
2020-05-18 21:41:31 +00:00
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
protected function setUp(): void {
|
2020-05-18 21:41:31 +00:00
|
|
|
parent::setUp();
|
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
|
|
|
}
|
|
|
|
|
|
2022-05-30 21:14:02 +00:00
|
|
|
public function testSpecialPageDoesNotFatal() {
|
2018-08-12 09:08:58 +00:00
|
|
|
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
|
|
|
|
|
foreach ( $spf->getNames() as $name ) {
|
2016-03-24 14:11:58 +00:00
|
|
|
|
2022-05-30 21:14:02 +00:00
|
|
|
$page = $spf->getPage( $name );
|
|
|
|
|
if ( !$page ) {
|
|
|
|
|
$this->markTestSkipped( "Could not create special page $name" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$executor = new SpecialPageExecutor();
|
|
|
|
|
$authority = new UltimateAuthority( new UserIdentityValue( 0, 'UTSysop' ) );
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$executor->executeSpecialPage( $page, '', null, 'qqx', $authority );
|
|
|
|
|
} catch ( \PHPUnit\Framework\Error\Error $error ) {
|
|
|
|
|
// Let phpunit settings working:
|
2022-12-02 20:54:42 +00:00
|
|
|
// - convertDeprecationsToExceptions="true"
|
2022-05-30 21:14:02 +00:00
|
|
|
// - convertErrorsToExceptions="true"
|
|
|
|
|
// - convertNoticesToExceptions="true"
|
|
|
|
|
// - convertWarningsToExceptions="true"
|
|
|
|
|
throw $error;
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
// Other exceptions are allowed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the page fataled phpunit will have already died
|
|
|
|
|
$this->addToAssertionCount( 1 );
|
2021-02-24 18:28:04 +00:00
|
|
|
}
|
2016-03-24 14:11:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|