3 use MediaWiki\MediaWikiServices
;
4 use MediaWiki\Permissions\UltimateAuthority
;
5 use MediaWiki\User\UserIdentityValue
;
8 * Test that runs against all registered special pages to make sure that regular
9 * execution of the special page does not cause a fatal error.
11 * UltimateAuthority is used to run as much of the special page code as possible without
12 * actually knowing the details of the special page.
19 class SpecialPageFatalTest
extends MediaWikiIntegrationTestCase
{
21 protected function setUp(): void
{
23 // Deprecations don't matter for what this test cares about. This made browser tests fail
24 // on many occasions already. (T236809)
25 $this->filterDeprecated( '//' );
28 public static function provideSpecialPageDoesNotFatal() {
29 $spf = MediaWikiServices
::getInstance()->getSpecialPageFactory();
30 foreach ( $spf->getNames() as $name ) {
31 yield
$name => [ $name ];
36 * @dataProvider provideSpecialPageDoesNotFatal
38 public function testSpecialPageDoesNotFatal( string $name ) {
39 $spf = $this->getServiceContainer()->getSpecialPageFactory();
41 $page = $spf->getPage( $name );
43 $this->markTestSkipped( "Could not create special page $name" );
46 $executor = new SpecialPageExecutor();
47 $authority = new UltimateAuthority( new UserIdentityValue( 42, 'SpecialPageTester' ) );
50 $executor->executeSpecialPage( $page, '', null, 'qqx', $authority );
51 } catch ( \PHPUnit\Framework\Error\Error
$error ) {
52 // Let phpunit settings working:
53 // - convertDeprecationsToExceptions="true"
54 // - convertErrorsToExceptions="true"
55 // - convertNoticesToExceptions="true"
56 // - convertWarningsToExceptions="true"
58 } catch ( Exception
$e ) {
59 // Other exceptions are allowed
62 // If the page fataled phpunit will have already died
63 $this->addToAssertionCount( 1 );