*/ 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 */ 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 ), ); } }