aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/specials/SpecialRestSandboxTest.php
blob: daec65c9238a619eba01a99828656841e873447d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

use MediaWiki\MainConfigNames;
use MediaWiki\Specials\SpecialRestSandbox;

/**
 * TODO: Add tests confirming the interactive portion of the sandbox loads properly
 *
 * @covers \MediaWiki\Specials\SpecialRestSandbox
 */
class SpecialRestSandboxTest extends SpecialPageTestBase {
	protected function setUp(): void {
		parent::setUp();

		$scriptPath = $this->getConfVar( MainConfigNames::ScriptPath );
		$this->overrideConfigValues( [
			MainConfigNames::RestSandboxSpecs => [
				'mw' => [
					'url' => $scriptPath . '/rest.php/specs/v0/module/-',
					'name' => 'MediaWiki REST API',
				]
			]
		] );
	}

	/**
	 * Returns a new instance of the special page under test.
	 *
	 * @return SpecialRestSandbox
	 */
	protected function newSpecialPage() {
		return new SpecialRestSandbox( $this->getServiceContainer()->getUrlUtils() );
	}

	public function testEnglishDisclaimerNotPresent() {
		[ $html ] = $this->executeSpecialPage( '', null, 'en' );
		$this->assertStringNotContainsString( 'cdx-message--notice', $html );
	}

	public function testNonEnglishDisclaimerPresent() {
		[ $html ] = $this->executeSpecialPage( '', null, 'qqx' );
		$this->assertStringContainsString( 'cdx-message--notice', $html );
	}
}