From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- tests/phpunit/includes/ImportTest.php | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/phpunit/includes/ImportTest.php (limited to 'tests/phpunit/includes/ImportTest.php') diff --git a/tests/phpunit/includes/ImportTest.php b/tests/phpunit/includes/ImportTest.php new file mode 100644 index 00000000..2fce6bfb --- /dev/null +++ b/tests/phpunit/includes/ImportTest.php @@ -0,0 +1,101 @@ + + */ +class ImportTest extends MediaWikiLangTestCase { + + private function getInputStreamSource( $xml ) { + $file = 'data:application/xml,' . $xml; + $status = ImportStreamSource::newFromFile( $file ); + if ( !$status->isGood() ) { + throw new MWException( "Cannot create InputStreamSource." ); + } + return $status->value; + } + + /** + * @covers WikiImporter::handlePage + * @dataProvider getRedirectXML + * @param string $xml + * @param string|null $redirectTitle + */ + public function testHandlePageContainsRedirect( $xml, $redirectTitle ) { + $source = $this->getInputStreamSource( $xml ); + + $redirect = null; + $callback = function ( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) use ( &$redirect ) { + if ( array_key_exists( 'redirect', $pageInfo ) ) { + $redirect = $pageInfo['redirect']; + } + }; + + $importer = new WikiImporter( $source ); + $importer->setPageOutCallback( $callback ); + $importer->doImport(); + + $this->assertEquals( $redirectTitle, $redirect ); + } + + public function getRedirectXML() { + return array( + array( + <<< EOF + + + Test + 0 + 21 + + + 20 + 2014-05-27T10:00:00Z + + Admin + 10 + + Admin moved page [[Test]] to [[Test22]] + #REDIRECT [[Test22]] + tq456o9x3abm7r9ozi6km8yrbbc56o6 + wikitext + text/x-wiki + + + +EOF + , + 'Test22' + ), + array( + <<< EOF + + + Test + 0 + 42 + + 421 + 2014-05-27T11:00:00Z + + Admin + 10 + + Abcd + n7uomjq96szt60fy5w3x7ahf7q8m8rh + wikitext + text/x-wiki + + + +EOF + , + null + ), + ); + } + +} -- cgit v1.2.3-54-g00ecf