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