3 use PHPUnit\Framework\TestSuite
;
4 use Wikimedia\Parsoid\ParserTests\TestFileReader
;
5 use Wikimedia\Parsoid\ParserTests\TestMode
as ParserTestMode
;
6 use Wikimedia\ScopedCallback
;
9 * This is the suite class for running tests with the legacy parser
10 * within a single .txt source file.
11 * It is not invoked directly. Use --filter to select files, or
12 * use parserTests.php.
14 class ParserTestFileSuite
extends TestSuite
{
17 private ParserTestRunner
$ptRunner;
18 private TestFileReader
$ptFileInfo;
20 /** @var ScopedCallback */
21 private $ptTeardownScope;
23 public function __construct( ParserTestRunner
$runner, string $name, string $fileName ) {
24 parent
::__construct( $name );
25 $this->ptRunner
= $runner;
27 $this->ptFileInfo
= TestFileReader
::read( $fileName, static function ( $msg ) {
28 wfDeprecatedMsg( $msg, '1.35', false, false );
30 } catch ( \Exception
$e ) {
31 // Friendlier wrapping for any syntax errors that might occur.
32 throw new RuntimeException(
33 $fileName . ': ' . $e->getMessage()
37 $skipMessage = $this->ptRunner
->getFileSkipMessage(
38 true, /* legacy parser */
39 $this->ptFileInfo
->fileOptions
,
42 // Don't bother doing anything else if a skip message is set.
43 if ( $skipMessage !== null ) {
47 $mode = new ParserTestMode( 'legacy' );
48 foreach ( $this->ptFileInfo
->testCases
as $test ) {
49 $this->addTest( new ParserIntegrationTest(
50 $this->ptRunner
, $fileName, $test, $mode, $skipMessage ),
51 [ 'Database', 'Parser', 'ParserTests' ] );
55 protected function setUp(): void
{
56 $this->ptTeardownScope
= $this->ptRunner
->addArticles(
57 $this->ptFileInfo
->articles
61 protected function tearDown(): void
{
62 if ( $this->ptTeardownScope
) {
63 ScopedCallback
::consume( $this->ptTeardownScope
);