| Index: trunk/phase3/tests/phpunit/includes/parser/ParserPreloadTest.php |
| — | — | @@ -0,0 +1,67 @@ |
| | 2 | +<?php |
| | 3 | +/** |
| | 4 | + * Basic tests for Parser::getPreloadText |
| | 5 | + * @author Antoine Musso |
| | 6 | + */ |
| | 7 | +class ParserPreloadTest extends MediaWikiTestCase { |
| | 8 | + private $testParser; |
| | 9 | + private $testParserOptions; |
| | 10 | + private $title; |
| | 11 | + |
| | 12 | + function setUp() { |
| | 13 | + $this->testParserOptions = new ParserOptions(); |
| | 14 | + |
| | 15 | + $this->testParser = new Parser(); |
| | 16 | + $this->testParser->Options( $this->testParserOptions ); |
| | 17 | + $this->testParser->clearState(); |
| | 18 | + |
| | 19 | + $this->title = Title::newFromText( 'Preload Test' ); |
| | 20 | + } |
| | 21 | + |
| | 22 | + function tearDown() { |
| | 23 | + unset( $this->testParser ); |
| | 24 | + unset( $this->title ); |
| | 25 | + } |
| | 26 | + |
| | 27 | + /** |
| | 28 | + * @covers Parser::getPreloadText |
| | 29 | + */ |
| | 30 | + function testPreloadSimpleText() { |
| | 31 | + $this->assertPreloaded( 'simple', 'simple' ); |
| | 32 | + } |
| | 33 | + |
| | 34 | + /** |
| | 35 | + * @covers Parser::getPreloadText |
| | 36 | + */ |
| | 37 | + function testPreloadedPreIsUnstripped() { |
| | 38 | + $this->assertPreloaded( |
| | 39 | + '<pre>monospaced</pre>', |
| | 40 | + '<pre>monospaced</pre>', |
| | 41 | + '<pre> in preloaded text must be unstripped (bug 27467)' |
| | 42 | + ); |
| | 43 | + } |
| | 44 | + |
| | 45 | + /** |
| | 46 | + * @covers Parser::getPreloadText |
| | 47 | + */ |
| | 48 | + function testPreloadedNowikiIsUnstripped() { |
| | 49 | + $this->assertPreloaded( |
| | 50 | + '<nowiki>[[Dummy title]]</nowiki>', |
| | 51 | + '<nowiki>[[Dummy title]]</nowiki>', |
| | 52 | + '<nowiki> in preloaded text must be unstripped (bug 27467)' |
| | 53 | + ); |
| | 54 | + } |
| | 55 | + |
| | 56 | + function assertPreloaded( $expected, $text, $msg='') { |
| | 57 | + $this->assertEquals( |
| | 58 | + $expected, |
| | 59 | + $this->testParser->getPreloadText( |
| | 60 | + $text, |
| | 61 | + $this->title, |
| | 62 | + $this->testParserOptions |
| | 63 | + ), |
| | 64 | + $msg |
| | 65 | + ); |
| | 66 | + } |
| | 67 | + |
| | 68 | +} |
| Property changes on: trunk/phase3/tests/phpunit/includes/parser/ParserPreloadTest.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 69 | + native |