summaryrefslogtreecommitdiff
path: root/www/wiki/tests/phpunit/includes/parser/ParserIntegrationTest.php
blob: 91653b5d86c5cfd82a4fb87cdaf5b24d31a6defe (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
use Wikimedia\ScopedCallback;

/**
 * This is the TestCase subclass for running a single parser test via the
 * ParserTestRunner integration test system.
 *
 * Note: the following groups are not used by PHPUnit.
 * The list in ParserTestFileSuite::__construct() is used instead.
 *
 * @group large
 * @group Database
 * @group Parser
 * @group ParserTests
 *
 * @covers Parser
 * @covers BlockLevelPass
 * @covers CoreParserFunctions
 * @covers CoreTagHooks
 * @covers Sanitizer
 * @covers Preprocessor
 * @covers Preprocessor_DOM
 * @covers Preprocessor_Hash
 * @covers DateFormatter
 * @covers LinkHolderArray
 * @covers StripState
 * @covers ParserOptions
 * @covers ParserOutput
 */
class ParserIntegrationTest extends PHPUnit\Framework\TestCase {

	use MediaWikiCoversValidator;

	/** @var array */
	private $ptTest;

	/** @var ParserTestRunner */
	private $ptRunner;

	/** @var ScopedCallback */
	private $ptTeardownScope;

	public function __construct( $runner, $fileName, $test ) {
		parent::__construct( 'testParse', [ '[details omitted]' ],
			basename( $fileName ) . ': ' . $test['desc'] );
		$this->ptTest = $test;
		$this->ptRunner = $runner;
	}

	public function testParse() {
		$this->ptRunner->getRecorder()->setTestCase( $this );
		$result = $this->ptRunner->runTest( $this->ptTest );
		$this->assertEquals( $result->expected, $result->actual );
	}

	public function setUp() {
		$this->ptTeardownScope = $this->ptRunner->staticSetup();
	}

	public function tearDown() {
		if ( $this->ptTeardownScope ) {
			ScopedCallback::consume( $this->ptTeardownScope );
		}
	}
}