Remove the deprecated Preprocessor_DOM class, which was hard-deprecated in 1.34. This begins to simplify parser configuration and reduce redundant code paths, but I've left two things for cleanup in a future patch: 1. The `preprocessorClass` configuration option to the parser, exposed in `$wgParserConf`, ServiceWiring, ParserFactory, etc. There is no reason for this to be exposed as configurable, but I've left this clean up to a future patch. 2. The `$wgMaxGeneratedPPNodeCount` configuration, exposed also in ParserOptions. Only Preprocessor_DOM calculated this count, and since we are only using Preprocessor_Hash now, this configuration has no effect. But since this value was exposed in ParserOptions and elsewhere, I've deprecated where needed but left this clean up to a future patch. Bug: T204945 Change-Id: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
88 lines
1.9 KiB
PHP
88 lines
1.9 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* Basic tests for Parser::getPreloadText
|
|
* @author Antoine Musso
|
|
*
|
|
* @covers Parser
|
|
* @covers StripState
|
|
*
|
|
* @covers Preprocessor_Hash
|
|
* @covers PPDStack_Hash
|
|
* @covers PPDStackElement_Hash
|
|
* @covers PPDPart_Hash
|
|
* @covers PPFrame_Hash
|
|
* @covers PPTemplateFrame_Hash
|
|
* @covers PPCustomFrame_Hash
|
|
* @covers PPNode_Hash_Tree
|
|
* @covers PPNode_Hash_Text
|
|
* @covers PPNode_Hash_Array
|
|
* @covers PPNode_Hash_Attr
|
|
*/
|
|
class ParserPreloadTest extends MediaWikiTestCase {
|
|
/**
|
|
* @var Parser
|
|
*/
|
|
private $testParser;
|
|
/**
|
|
* @var ParserOptions
|
|
*/
|
|
private $testParserOptions;
|
|
/**
|
|
* @var Title
|
|
*/
|
|
private $title;
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
$this->testParserOptions = ParserOptions::newFromUserAndLang( new User,
|
|
MediaWikiServices::getInstance()->getContentLanguage() );
|
|
|
|
$this->testParser = new Parser();
|
|
$this->testParser->Options( $this->testParserOptions );
|
|
$this->testParser->clearState();
|
|
|
|
$this->title = Title::newFromText( 'Preload Test' );
|
|
}
|
|
|
|
protected function tearDown() : void {
|
|
parent::tearDown();
|
|
|
|
unset( $this->testParser );
|
|
unset( $this->title );
|
|
}
|
|
|
|
public function testPreloadSimpleText() {
|
|
$this->assertPreloaded( 'simple', 'simple' );
|
|
}
|
|
|
|
public function testPreloadedPreIsUnstripped() {
|
|
$this->assertPreloaded(
|
|
'<pre>monospaced</pre>',
|
|
'<pre>monospaced</pre>',
|
|
'<pre> in preloaded text must be unstripped (T29467)'
|
|
);
|
|
}
|
|
|
|
public function testPreloadedNowikiIsUnstripped() {
|
|
$this->assertPreloaded(
|
|
'<nowiki>[[Dummy title]]</nowiki>',
|
|
'<nowiki>[[Dummy title]]</nowiki>',
|
|
'<nowiki> in preloaded text must be unstripped (T29467)'
|
|
);
|
|
}
|
|
|
|
protected function assertPreloaded( $expected, $text, $msg = '' ) {
|
|
$this->assertEquals(
|
|
$expected,
|
|
$this->testParser->getPreloadText(
|
|
$text,
|
|
$this->title,
|
|
$this->testParserOptions
|
|
),
|
|
$msg
|
|
);
|
|
}
|
|
}
|