Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / structure / SpecialPageFatalTest.php
blobb7778ba34e45999bed083b4b3d897399d6fd7f63
1 <?php
3 use MediaWiki\MediaWikiServices;
4 use MediaWiki\Permissions\UltimateAuthority;
5 use MediaWiki\User\UserIdentityValue;
7 /**
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.
14 * @since 1.32
15 * @author Addshore
16 * @coversNothing
17 * @group Database
19 class SpecialPageFatalTest extends MediaWikiIntegrationTestCase {
21 protected function setUp(): void {
22 parent::setUp();
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 ];
35 /**
36 * @dataProvider provideSpecialPageDoesNotFatal
38 public function testSpecialPageDoesNotFatal( string $name ) {
39 $spf = $this->getServiceContainer()->getSpecialPageFactory();
41 $page = $spf->getPage( $name );
42 if ( !$page ) {
43 $this->markTestSkipped( "Could not create special page $name" );
46 $executor = new SpecialPageExecutor();
47 $authority = new UltimateAuthority( new UserIdentityValue( 42, 'SpecialPageTester' ) );
49 try {
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"
57 throw $error;
58 } catch ( Exception $e ) {
59 // Other exceptions are allowed
62 // If the page fataled phpunit will have already died
63 $this->addToAssertionCount( 1 );