SpecialPageFatalTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use MediaWiki\MediaWikiServices;
  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. public function provideSpecialPages() {
  15. $specialPages = [];
  16. $spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
  17. foreach ( $spf->getNames() as $name ) {
  18. $specialPages[$name] = [ $spf->getPage( $name ) ];
  19. }
  20. return $specialPages;
  21. }
  22. /**
  23. * @dataProvider provideSpecialPages
  24. */
  25. public function testSpecialPageDoesNotFatal( SpecialPage $page ) {
  26. $executor = new SpecialPageExecutor();
  27. $user = User::newFromName( 'UTSysop' );
  28. try {
  29. $executor->executeSpecialPage( $page, '', null, null, $user );
  30. } catch ( Exception $e ) {
  31. // Exceptions are allowed
  32. }
  33. // If the page fataled phpunit will have already died
  34. $this->addToAssertionCount( 1 );
  35. }
  36. }