wiki.techinc.nl/tests/phpunit/includes/parser/ParserIntegrationTest.php
Timo Tijhof 14644a2fb0 phpunit: Add some @covers and @large/@medium to integration tests
- @small: single class, no I/O (unit test).
- @medium: multi-class (partial or no mocks), no I/O (unit/integration test).
- @large: multi-class, I/O allowed (integration test).

Change-Id: I09317e6dd9b0ee34b7467fbffdd07957ef55dc04
2018-03-20 09:14:34 -07:00

65 lines
1.5 KiB
PHP

<?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.
*
* @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 );
}
}
}