MediaWiki  REL1_22
ParserPreloadTest.php
Go to the documentation of this file.
00001 <?php
00006 class ParserPreloadTest extends MediaWikiTestCase {
00010     private $testParser;
00014     private $testParserOptions;
00018     private $title;
00019 
00020     protected function setUp() {
00021         global $wgContLang;
00022 
00023         parent::setUp();
00024         $this->testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang );
00025 
00026         $this->testParser = new Parser();
00027         $this->testParser->Options( $this->testParserOptions );
00028         $this->testParser->clearState();
00029 
00030         $this->title = Title::newFromText( 'Preload Test' );
00031     }
00032 
00033     protected function tearDown() {
00034         parent::tearDown();
00035 
00036         unset( $this->testParser );
00037         unset( $this->title );
00038     }
00039 
00043     public function testPreloadSimpleText() {
00044         $this->assertPreloaded( 'simple', 'simple' );
00045     }
00046 
00050     public function testPreloadedPreIsUnstripped() {
00051         $this->assertPreloaded(
00052             '<pre>monospaced</pre>',
00053             '<pre>monospaced</pre>',
00054             '<pre> in preloaded text must be unstripped (bug 27467)'
00055         );
00056     }
00057 
00061     public function testPreloadedNowikiIsUnstripped() {
00062         $this->assertPreloaded(
00063             '<nowiki>[[Dummy title]]</nowiki>',
00064             '<nowiki>[[Dummy title]]</nowiki>',
00065             '<nowiki> in preloaded text must be unstripped (bug 27467)'
00066         );
00067     }
00068 
00069     protected function assertPreloaded( $expected, $text, $msg = '' ) {
00070         $this->assertEquals(
00071             $expected,
00072             $this->testParser->getPreloadText(
00073                 $text,
00074                 $this->title,
00075                 $this->testParserOptions
00076             ),
00077             $msg
00078         );
00079     }
00080 }