X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/d57edfddd6c01f0ed6b1a84019649cdf6cddd5f8..83d871ca0d985c6d586b323bf96161afb510ebf6:/tests/phpunit/includes/parser/ParserPreloadTest.php diff --git a/tests/phpunit/includes/parser/ParserPreloadTest.php b/tests/phpunit/includes/parser/ParserPreloadTest.php new file mode 100644 index 00000000..77073955 --- /dev/null +++ b/tests/phpunit/includes/parser/ParserPreloadTest.php @@ -0,0 +1,95 @@ +testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang ); + + $this->testParser = new Parser(); + $this->testParser->Options( $this->testParserOptions ); + $this->testParser->clearState(); + + $this->title = Title::newFromText( 'Preload Test' ); + } + + protected function tearDown() { + parent::tearDown(); + + unset( $this->testParser ); + unset( $this->title ); + } + + public function testPreloadSimpleText() { + $this->assertPreloaded( 'simple', 'simple' ); + } + + public function testPreloadedPreIsUnstripped() { + $this->assertPreloaded( + '
monospaced', + '
monospaced', + '
in preloaded text must be unstripped (T29467)' + ); + } + + public function testPreloadedNowikiIsUnstripped() { + $this->assertPreloaded( + '[[Dummy title]] ', + '[[Dummy title]] ', + 'in preloaded text must be unstripped (T29467)' + ); + } + + protected function assertPreloaded( $expected, $text, $msg = '' ) { + $this->assertEquals( + $expected, + $this->testParser->getPreloadText( + $text, + $this->title, + $this->testParserOptions + ), + $msg + ); + } +}