Merge "Call $wgContLang->findVariantLink() in {{PAGESINCATEGORY: }}"
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / ParserPreloadTest.php
1 <?php
2 /**
3 * Basic tests for Parser::getPreloadText
4 * @author Antoine Musso
5 */
6 class ParserPreloadTest extends MediaWikiTestCase {
7 private $testParser;
8 private $testParserOptions;
9 private $title;
10
11 protected function setUp() {
12 global $wgContLang;
13
14 parent::setUp();
15 $this->testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang );
16
17 $this->testParser = new Parser();
18 $this->testParser->Options( $this->testParserOptions );
19 $this->testParser->clearState();
20
21 $this->title = Title::newFromText( 'Preload Test' );
22 }
23
24 protected function tearDown() {
25 parent::tearDown();
26
27 unset( $this->testParser );
28 unset( $this->title );
29 }
30
31 /**
32 * @covers Parser::getPreloadText
33 */
34 function testPreloadSimpleText() {
35 $this->assertPreloaded( 'simple', 'simple' );
36 }
37
38 /**
39 * @covers Parser::getPreloadText
40 */
41 function testPreloadedPreIsUnstripped() {
42 $this->assertPreloaded(
43 '<pre>monospaced</pre>',
44 '<pre>monospaced</pre>',
45 '<pre> in preloaded text must be unstripped (bug 27467)'
46 );
47 }
48
49 /**
50 * @covers Parser::getPreloadText
51 */
52 function testPreloadedNowikiIsUnstripped() {
53 $this->assertPreloaded(
54 '<nowiki>[[Dummy title]]</nowiki>',
55 '<nowiki>[[Dummy title]]</nowiki>',
56 '<nowiki> in preloaded text must be unstripped (bug 27467)'
57 );
58 }
59
60 function assertPreloaded( $expected, $text, $msg = '' ) {
61 $this->assertEquals(
62 $expected,
63 $this->testParser->getPreloadText(
64 $text,
65 $this->title,
66 $this->testParserOptions
67 ),
68 $msg
69 );
70 }
71 }