Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / parser / ParserPreloadTest.php
blobd12fee368ff92d2710c897f208d5b0a0430f0f48
1 <?php
2 /**
3 * Basic tests for Parser::getPreloadText
4 * @author Antoine Musso
5 */
6 class ParserPreloadTest extends MediaWikiTestCase {
7 /**
8 * @var Parser
9 */
10 private $testParser;
11 /**
12 * @var ParserOptions
14 private $testParserOptions;
15 /**
16 * @var Title
18 private $title;
20 protected function setUp() {
21 global $wgContLang;
23 parent::setUp();
24 $this->testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang );
26 $this->testParser = new Parser();
27 $this->testParser->Options( $this->testParserOptions );
28 $this->testParser->clearState();
30 $this->title = Title::newFromText( 'Preload Test' );
33 protected function tearDown() {
34 parent::tearDown();
36 unset( $this->testParser );
37 unset( $this->title );
40 /**
41 * @covers Parser::getPreloadText
43 public function testPreloadSimpleText() {
44 $this->assertPreloaded( 'simple', 'simple' );
47 /**
48 * @covers Parser::getPreloadText
50 public function testPreloadedPreIsUnstripped() {
51 $this->assertPreloaded(
52 '<pre>monospaced</pre>',
53 '<pre>monospaced</pre>',
54 '<pre> in preloaded text must be unstripped (bug 27467)'
58 /**
59 * @covers Parser::getPreloadText
61 public function testPreloadedNowikiIsUnstripped() {
62 $this->assertPreloaded(
63 '<nowiki>[[Dummy title]]</nowiki>',
64 '<nowiki>[[Dummy title]]</nowiki>',
65 '<nowiki> in preloaded text must be unstripped (bug 27467)'
69 protected function assertPreloaded( $expected, $text, $msg = '' ) {
70 $this->assertEquals(
71 $expected,
72 $this->testParser->getPreloadText(
73 $text,
74 $this->title,
75 $this->testParserOptions
77 $msg