MessageCache::destroyInstance() is static.
[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 function setUp() {
12 $this->testParserOptions = new ParserOptions();
13
14 $this->testParser = new Parser();
15 $this->testParser->Options( $this->testParserOptions );
16 $this->testParser->clearState();
17
18 $this->title = Title::newFromText( 'Preload Test' );
19 }
20
21 function tearDown() {
22 unset( $this->testParser );
23 unset( $this->title );
24 }
25
26 /**
27 * @covers Parser::getPreloadText
28 */
29 function testPreloadSimpleText() {
30 $this->assertPreloaded( 'simple', 'simple' );
31 }
32
33 /**
34 * @covers Parser::getPreloadText
35 */
36 function testPreloadedPreIsUnstripped() {
37 $this->assertPreloaded(
38 '<pre>monospaced</pre>',
39 '<pre>monospaced</pre>',
40 '<pre> in preloaded text must be unstripped (bug 27467)'
41 );
42 }
43
44 /**
45 * @covers Parser::getPreloadText
46 */
47 function testPreloadedNowikiIsUnstripped() {
48 $this->assertPreloaded(
49 '<nowiki>[[Dummy title]]</nowiki>',
50 '<nowiki>[[Dummy title]]</nowiki>',
51 '<nowiki> in preloaded text must be unstripped (bug 27467)'
52 );
53 }
54
55 function assertPreloaded( $expected, $text, $msg='') {
56 $this->assertEquals(
57 $expected,
58 $this->testParser->getPreloadText(
59 $text,
60 $this->title,
61 $this->testParserOptions
62 ),
63 $msg
64 );
65 }
66
67 }