diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
commit | 63601400e476c6cf43d985f3e7b9864681695ed4 (patch) | |
tree | f7846203a952e38aaf66989d0a4702779f549962 /tests/phpunit/includes/parser | |
parent | 8ff01378c9e0207f9169b81966a51def645b6a51 (diff) |
Update to MediaWiki 1.20.2
this update includes:
* adjusted Arch Linux skin
* updated FluxBBAuthPlugin
* patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'tests/phpunit/includes/parser')
4 files changed, 46 insertions, 11 deletions
diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php index 816c017a..6a6fded1 100644 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -1,5 +1,5 @@ <?php -require_once( dirname( __FILE__ ) . '/NewParserTest.php' ); +require_once( __DIR__ . '/NewParserTest.php' ); /** * The UnitTest must be either a class that inherits from MediaWikiTestCase diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index d9b16710..69a96e66 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -186,7 +186,7 @@ class NewParserTest extends MediaWikiTestCase { if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { $image->recordUpload2( '', // archive name - 'Upload of some lame file', + 'Upload of some lame file', 'Some lame file', array( 'size' => 12345, @@ -197,7 +197,7 @@ class NewParserTest extends MediaWikiTestCase { 'mime' => 'image/jpeg', 'metadata' => serialize( array() ), 'sha1' => wfBaseConvert( '', 16, 36, 31 ), - 'fileExists' => true ), + 'fileExists' => true ), $this->db->timestamp( '20010115123500' ), $user ); } @@ -207,8 +207,8 @@ class NewParserTest extends MediaWikiTestCase { if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { $image->recordUpload2( '', // archive name - 'zomgnotcensored', - 'Borderline image', + 'zomgnotcensored', + 'Borderline image', array( 'size' => 12345, 'width' => 320, @@ -218,7 +218,7 @@ class NewParserTest extends MediaWikiTestCase { 'mime' => 'image/jpeg', 'metadata' => serialize( array() ), 'sha1' => wfBaseConvert( '', 16, 36, 31 ), - 'fileExists' => true ), + 'fileExists' => true ), $this->db->timestamp( '20010115123500' ), $user ); } @@ -326,7 +326,6 @@ class NewParserTest extends MediaWikiTestCase { 'wgExternalLinkTarget' => false, 'wgAlwaysUseTidy' => false, 'wgHtml5' => true, - 'wgCleanupPresentationalAttributes' => true, 'wgWellFormedXml' => true, 'wgAllowMicrodataAttributes' => true, 'wgAdaptiveMessageCache' => true, @@ -345,6 +344,9 @@ class NewParserTest extends MediaWikiTestCase { $this->savedGlobals = array(); + /** @since 1.20 */ + wfRunHooks( 'ParserTestGlobals', array( &$settings ) ); + foreach ( $settings as $var => $val ) { if ( array_key_exists( $var, $GLOBALS ) ) { $this->savedGlobals[$var] = $GLOBALS[$var]; @@ -380,7 +382,7 @@ class NewParserTest extends MediaWikiTestCase { # The entries saved into RepoGroup cache with previous globals will be wrong. RepoGroup::destroySingleton(); FileBackendGroup::destroySingleton(); - MessageCache::singleton()->destroyInstance(); + MessageCache::destroyInstance(); return $context; } @@ -596,7 +598,7 @@ class NewParserTest extends MediaWikiTestCase { * Run a fuzz test series * Draw input from a set of test files * - * @todo @fixme Needs some work to not eat memory until the world explodes + * @todo fixme Needs some work to not eat memory until the world explodes * * @group ParserFuzz */ diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php new file mode 100644 index 00000000..dea406c3 --- /dev/null +++ b/tests/phpunit/includes/parser/ParserMethodsTest.php @@ -0,0 +1,33 @@ +<?php + +class ParserMethodsTest extends MediaWikiLangTestCase { + + public function dataPreSaveTransform() { + return array( + array( 'hello this is ~~~', + "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]", + ), + array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>', + 'hello \'\'this\'\' is <nowiki>~~~</nowiki>', + ), + ); + } + + /** + * @dataProvider dataPreSaveTransform + */ + public function testPreSaveTransform( $text, $expected ) { + global $wgParser; + + $title = Title::newFromText( str_replace( '::', '__', __METHOD__ ) ); + $user = new User(); + $user->setName( "127.0.0.1" ); + $popts = ParserOptions::newFromUser( $user ); + $text = $wgParser->preSaveTransform( $text, $title, $user, $popts ); + + $this->assertEquals( $expected, $text ); + } + + // TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText() +} + diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php index 9d3499a0..fee56748 100644 --- a/tests/phpunit/includes/parser/PreprocessorTest.php +++ b/tests/phpunit/includes/parser/PreprocessorTest.php @@ -103,7 +103,7 @@ class PreprocessorTest extends MediaWikiTestCase { array( "{{foo|bar=|}", "<root>{{foo|bar=|}</root>"), array( "{{Foo|} Bar=", "<root>{{Foo|} Bar=</root>"), array( "{{Foo|} Bar=}}", "<root><template><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root>"), - /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */ + /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */ ); } @@ -165,7 +165,7 @@ class PreprocessorTest extends MediaWikiTestCase { * @dataProvider provideFiles */ function testPreprocessorOutputFiles( $filename ) { - $folder = dirname( __FILE__ ) . "/../../../parser/preprocess"; + $folder = __DIR__ . "/../../../parser/preprocess"; $wikiText = file_get_contents( "$folder/$filename.txt" ); $output = $this->preprocessToXml( $wikiText ); |