Trying to avoid resetting services introduces a lot of complexity and several bugs. We were doing a reset for 70% of @group Database tests anyway. Instead: * Reset services at the start of MediaWikiTestCase::run(). * Capture the actual original service container instead of making a special shared service container. * The test-isolated local service container can now only be initialised non-statically. Revert the recent conversion of overrideMwServices() to static. * Store a reference to the local service container in the test case object. In MediaWikiTestCase, always use the original or local service container directly, to avoid confusion about which one is active at the time. * Remove a lot of unnecessary teardown * Always call ServiceContainer::destroy() before forceGlobalInstance() since the memory is not otherwise freed. Change-Id: I4a17c1c7ec92c14e3bc471f0216473ebe19477b9
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* 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 = [];
|
|
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
|
|
foreach ( $spf->getNames() as $name ) {
|
|
$specialPages[$name] = [ $spf->getPage( $name ) ];
|
|
}
|
|
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 );
|
|
}
|
|
|
|
}
|