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 assertPostConditions(): void
{
31 $obLevel = ob_get_level();
32 if ( $obLevel !== $this->obLevel
) {
34 "Test changed output buffer level: was {$this->obLevel} before test, but $obLevel after test."
37 parent
::assertPostConditions();
40 protected function tearDown(): void
{
41 while ( ob_get_level() > $this->obLevel
) {
48 * Returns a new instance of the special page under test.
52 abstract protected function newSpecialPage();
55 * @param string|null $subPage The subpage parameter to call the page with
56 * @param WebRequest|null $request Web request that may contain URL parameters, etc
57 * @param Language|string|null $language The language which should be used in the context;
59 * @param Authority|null $performer The user which should be used in the context of this special page
60 * @param bool $fullHtml if true, the entirety of the generated HTML will be returned, this
61 * includes the opening <!DOCTYPE> declaration and closing </html> tag. If false, only value
62 * of OutputPage::getHTML() will be returned except if the page is redirect or where OutputPage
63 * is completely disabled.
65 * @return array [ string, WebResponse ] A two-elements array containing the HTML output
66 * generated by the special page as well as the response object.
68 protected function executeSpecialPage(
70 ?WebRequest
$request = null,
72 ?Authority
$performer = null,
75 return ( new SpecialPageExecutor() )->executeSpecialPage(
76 $this->newSpecialPage(),