MediaWiki  REL1_21
ParserPreloadTest.php
Go to the documentation of this file.
00001 <?php
00006 class ParserPreloadTest extends MediaWikiTestCase {
00007         private $testParser;
00008         private $testParserOptions;
00009         private $title;
00010 
00011         protected function setUp() {
00012                 global $wgContLang;
00013 
00014                 parent::setUp();
00015                 $this->testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang );
00016 
00017                 $this->testParser = new Parser();
00018                 $this->testParser->Options( $this->testParserOptions );
00019                 $this->testParser->clearState();
00020 
00021                 $this->title = Title::newFromText( 'Preload Test' );
00022         }
00023 
00024         protected function tearDown() {
00025                 parent::tearDown();
00026 
00027                 unset( $this->testParser );
00028                 unset( $this->title );
00029         }
00030 
00034         function testPreloadSimpleText() {
00035                 $this->assertPreloaded( 'simple', 'simple' );
00036         }
00037 
00041         function testPreloadedPreIsUnstripped() {
00042                 $this->assertPreloaded(
00043                         '<pre>monospaced</pre>',
00044                         '<pre>monospaced</pre>',
00045                         '<pre> in preloaded text must be unstripped (bug 27467)'
00046                 );
00047         }
00048 
00052         function testPreloadedNowikiIsUnstripped() {
00053                 $this->assertPreloaded(
00054                         '<nowiki>[[Dummy title]]</nowiki>',
00055                         '<nowiki>[[Dummy title]]</nowiki>',
00056                         '<nowiki> in preloaded text must be unstripped (bug 27467)'
00057                 );
00058         }
00059 
00060         function assertPreloaded( $expected, $text, $msg = '' ) {
00061                 $this->assertEquals(
00062                         $expected,
00063                         $this->testParser->getPreloadText(
00064                                 $text,
00065                                 $this->title,
00066                                 $this->testParserOptions
00067                         ),
00068                         $msg
00069                 );
00070         }
00071 
00072 }