3 use MediaWiki\MediaWikiServices
;
6 * Basic tests for Parser::getPreloadText
7 * @author Antoine Musso
12 * @covers Preprocessor_DOM
14 * @covers PPDStackElement
17 * @covers PPTemplateFrame_DOM
18 * @covers PPCustomFrame_DOM
21 * @covers Preprocessor_Hash
22 * @covers PPDStack_Hash
23 * @covers PPDStackElement_Hash
24 * @covers PPDPart_Hash
25 * @covers PPFrame_Hash
26 * @covers PPTemplateFrame_Hash
27 * @covers PPCustomFrame_Hash
28 * @covers PPNode_Hash_Tree
29 * @covers PPNode_Hash_Text
30 * @covers PPNode_Hash_Array
31 * @covers PPNode_Hash_Attr
33 class ParserPreloadTest
extends \MediaWikiUnitTestCase
{
41 private $testParserOptions;
47 protected function setUp() {
49 $this->testParserOptions
= ParserOptions
::newFromUserAndLang( new User
,
50 MediaWikiServices
::getInstance()->getContentLanguage() );
52 $this->testParser
= new Parser();
53 $this->testParser
->Options( $this->testParserOptions
);
54 $this->testParser
->clearState();
56 $this->title
= Title
::newFromText( 'Preload Test' );
59 protected function tearDown() {
62 unset( $this->testParser
);
63 unset( $this->title
);
66 public function testPreloadSimpleText() {
67 $this->assertPreloaded( 'simple', 'simple' );
70 public function testPreloadedPreIsUnstripped() {
71 $this->assertPreloaded(
72 '<pre>monospaced</pre>',
73 '<pre>monospaced</pre>',
74 '<pre> in preloaded text must be unstripped (T29467)'
78 public function testPreloadedNowikiIsUnstripped() {
79 $this->assertPreloaded(
80 '<nowiki>[[Dummy title]]</nowiki>',
81 '<nowiki>[[Dummy title]]</nowiki>',
82 '<nowiki> in preloaded text must be unstripped (T29467)'
86 protected function assertPreloaded( $expected, $text, $msg = '' ) {
89 $this->testParser
->getPreloadText(
92 $this->testParserOptions