MediaWiki REL1_32
ParserPreloadTest.php
Go to the documentation of this file.
1<?php
2
4
37 private $testParser;
45 private $title;
46
47 protected function setUp() {
48 parent::setUp();
49 $this->testParserOptions = ParserOptions::newFromUserAndLang( new User,
50 MediaWikiServices::getInstance()->getContentLanguage() );
51
52 $this->testParser = new Parser();
53 $this->testParser->Options( $this->testParserOptions );
54 $this->testParser->clearState();
55
56 $this->title = Title::newFromText( 'Preload Test' );
57 }
58
59 protected function tearDown() {
60 parent::tearDown();
61
62 unset( $this->testParser );
63 unset( $this->title );
64 }
65
66 public function testPreloadSimpleText() {
67 $this->assertPreloaded( 'simple', 'simple' );
68 }
69
70 public function testPreloadedPreIsUnstripped() {
71 $this->assertPreloaded(
72 '<pre>monospaced</pre>',
73 '<pre>monospaced</pre>',
74 '<pre> in preloaded text must be unstripped (T29467)'
75 );
76 }
77
79 $this->assertPreloaded(
80 '<nowiki>[[Dummy title]]</nowiki>',
81 '<nowiki>[[Dummy title]]</nowiki>',
82 '<nowiki> in preloaded text must be unstripped (T29467)'
83 );
84 }
85
86 protected function assertPreloaded( $expected, $text, $msg = '' ) {
87 $this->assertEquals(
88 $expected,
89 $this->testParser->getPreloadText(
90 $text,
91 $this->title,
92 $this->testParserOptions
93 ),
94 $msg
95 );
96 }
97}
MediaWikiServices is the service locator for the application scope of MediaWiki.
Set options of the Parser.
Basic tests for Parser::getPreloadText.
ParserOptions $testParserOptions
assertPreloaded( $expected, $text, $msg='')
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:68
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:47