3 namespace MediaWiki\Tests\Parser
;
5 use MediaWiki\Parser\Parser
;
6 use MediaWiki\Parser\ParserOptions
;
7 use MediaWiki\Title\Title
;
8 use MediaWiki\User\User
;
9 use MediaWikiIntegrationTestCase
;
12 * Basic tests for Parser::getPreloadText
13 * @author Antoine Musso
15 * @covers \MediaWiki\Parser\Parser
16 * @covers \MediaWiki\Parser\StripState
18 * @covers \MediaWiki\Parser\Preprocessor_Hash
19 * @covers \MediaWiki\Parser\PPDStack_Hash
20 * @covers \MediaWiki\Parser\PPDStackElement_Hash
21 * @covers \MediaWiki\Parser\PPDPart_Hash
22 * @covers \MediaWiki\Parser\PPFrame_Hash
23 * @covers \MediaWiki\Parser\PPTemplateFrame_Hash
24 * @covers \MediaWiki\Parser\PPCustomFrame_Hash
25 * @covers \MediaWiki\Parser\PPNode_Hash_Tree
26 * @covers \MediaWiki\Parser\PPNode_Hash_Text
27 * @covers \MediaWiki\Parser\PPNode_Hash_Array
28 * @covers \MediaWiki\Parser\PPNode_Hash_Attr
30 class ParserPreloadTest
extends MediaWikiIntegrationTestCase
{
38 private $testParserOptions;
44 protected function setUp(): void
{
46 $services = $this->getServiceContainer();
48 $this->testParserOptions
= ParserOptions
::newFromUserAndLang( new User
,
49 $this->getServiceContainer()->getContentLanguage() );
51 $this->testParser
= $services->getParserFactory()->create();
52 $this->testParser
->setOptions( $this->testParserOptions
);
53 $this->testParser
->clearState();
55 $this->title
= Title
::makeTitle( NS_MAIN
, 'Preload Test' );
58 public function testPreloadSimpleText() {
59 $this->assertPreloaded( 'simple', 'simple' );
62 public function testPreloadedPreIsUnstripped() {
63 $this->assertPreloaded(
64 '<pre>monospaced</pre>',
65 '<pre>monospaced</pre>',
66 '<pre> in preloaded text must be unstripped (T29467)'
70 public function testPreloadedNowikiIsUnstripped() {
71 $this->assertPreloaded(
72 '<nowiki>[[Dummy title]]</nowiki>',
73 '<nowiki>[[Dummy title]]</nowiki>',
74 '<nowiki> in preloaded text must be unstripped (T29467)'
78 protected function assertPreloaded( $expected, $text, $msg = '' ) {
81 $this->testParser
->getPreloadText(
84 $this->testParserOptions