Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / tests / phpunit / includes / specials / SpecialPageTestBase.php
blob2f091d5d064cc017ddbca74bc9ac3a7f26d1b721
1 <?php
3 /**
4 * Base class for testing special pages.
6 * @since 1.26
8 * @licence GNU GPL v2+
9 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
10 * @author Daniel Kinzler
11 * @author Addshore
12 * @author Thiemo Mättig
14 abstract class SpecialPageTestBase extends MediaWikiTestCase {
16 private $obLevel;
18 protected function setUp() {
19 parent::setUp();
21 $this->obLevel = ob_get_level();
24 protected function tearDown() {
25 $obLevel = ob_get_level();
27 while ( ob_get_level() > $this->obLevel ) {
28 ob_end_clean();
31 if ( $obLevel !== $this->obLevel ) {
32 $this->fail(
33 "Test changed output buffer level: was {$this->obLevel} before test, but $obLevel after test."
37 parent::tearDown();
40 /**
41 * Returns a new instance of the special page under test.
43 * @return SpecialPage
45 abstract protected function newSpecialPage();
47 /**
48 * @param string $subPage The subpage parameter to call the page with
49 * @param WebRequest|null $request Web request that may contain URL parameters, etc
50 * @param Language|string|null $language The language which should be used in the context
51 * @param User|null $user The user which should be used in the context of this special page
53 * @throws Exception
54 * @return array( string, WebResponse ) A two-elements array containing the HTML output
55 * generated by the special page as well as the response object.
57 protected function executeSpecialPage(
58 $subPage = '',
59 WebRequest $request = null,
60 $language = null,
61 User $user = null
62 ) {
63 return ( new SpecialPageExecutor() )->executeSpecialPage(
64 $this->newSpecialPage(),
65 $subPage,
66 $request,
67 $language,
68 $user