3 use MediaWiki\Language\Language
;
4 use MediaWiki\Permissions\Authority
;
5 use MediaWiki\Request\WebRequest
;
6 use MediaWiki\SpecialPage\SpecialPage
;
9 * Base class for testing special pages.
13 * @license GPL-2.0-or-later
14 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
15 * @author Daniel Kinzler
17 * @author Thiemo Kreuz
19 abstract class SpecialPageTestBase
extends MediaWikiIntegrationTestCase
{
24 protected function setUp(): void
{
27 $this->obLevel
= ob_get_level();
30 protected function tearDown(): void
{
31 $obLevel = ob_get_level();
33 while ( ob_get_level() > $this->obLevel
) {
38 if ( $obLevel !== $this->obLevel
) {
40 "Test changed output buffer level: was {$this->obLevel} before test, but $obLevel after test."
49 * Returns a new instance of the special page under test.
53 abstract protected function newSpecialPage();
56 * @param string|null $subPage The subpage parameter to call the page with
57 * @param WebRequest|null $request Web request that may contain URL parameters, etc
58 * @param Language|string|null $language The language which should be used in the context;
60 * @param Authority|null $performer The user which should be used in the context of this special page
61 * @param bool $fullHtml if true, the entirety of the generated HTML will be returned, this
62 * includes the opening <!DOCTYPE> declaration and closing </html> tag. If false, only value
63 * of OutputPage::getHTML() will be returned except if the page is redirect or where OutputPage
64 * is completely disabled.
66 * @return array [ string, WebResponse ] A two-elements array containing the HTML output
67 * generated by the special page as well as the response object.
69 protected function executeSpecialPage(
71 ?WebRequest
$request = null,
73 ?Authority
$performer = null,
76 return ( new SpecialPageExecutor() )->executeSpecialPage(
77 $this->newSpecialPage(),