47dbd2e02e22b4fbffa7dfac6327ea9d8d3cd225
[lhc/web/wiklou.git] / tests / phpunit / structure / SpecialPageFatalTest.php
1 <?php
2
3 /**
4 * Test that runs against all registered special pages to make sure that regular
5 * execution of the special page does not cause a fatal error.
6 *
7 * UTSysop is used to run as much of the special page code as possible without
8 * actually knowing the details of the special page.
9 *
10 * @since 1.32
11 * @author Addshore
12 */
13 class SpecialPageFatalTest extends MediaWikiTestCase {
14
15 public static function setUpBeforeClass() {
16 parent::setUpBeforeClass();
17 self::overrideMwServices();
18 }
19
20 public static function tearDownAfterClass() {
21 self::overrideMwServices();
22 parent::tearDownAfterClass();
23 }
24
25 public function provideSpecialPages() {
26 $specialPages = [];
27 foreach ( SpecialPageFactory::getNames() as $name ) {
28 $specialPages[$name] = [ SpecialPageFactory::getPage( $name ) ];
29 }
30 return $specialPages;
31 }
32
33 /**
34 * @dataProvider provideSpecialPages
35 */
36 public function testSpecialPageDoesNotFatal( SpecialPage $page ) {
37 $executor = new SpecialPageExecutor();
38 $user = User::newFromName( 'UTSysop' );
39
40 try {
41 $executor->executeSpecialPage( $page, '', null, null, $user );
42 } catch ( Exception $e ) {
43 // Exceptions are allowed
44 }
45
46 // If the page fataled phpunit will have already died
47 $this->addToAssertionCount( 1 );
48 }
49
50 }