wiki.techinc.nl/tests/phpunit/structure/SpecialPageFatalTest.php
Umherirrender 7d7820fb4a Relax SpecialPageFatalTest about deprecation notices
Deprecation notice from SpecialPageFatalTest is the most merge blocker
since merge of I8fb26380724b6b12bf08458dbff2e00b759d219b
Deprecation can occur at any time and than break many extensions to
merge, even there are still working.
Ignore deprecation as before, but keep the error and notices

Change-Id: Idcbc38b662c569fbe8e778a6b1ab815db332dc08
2019-04-19 20:18:22 +02:00

52 lines
1.5 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
* @coversNothing
*/
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 ( \PHPUnit\Framework\Error\Deprecated $deprecated ) {
// Allow deprecation,
// this test want to check fatals or other things breaking the extension
} catch ( \PHPUnit\Framework\Error\Error $error ) {
// Let phpunit settings working:
// - 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 );
}
}