*/
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;
+ private function getDataSource( $xml ) {
+ return new ImportStringSource( $xml );
}
/**
* @param string|null $redirectTitle
*/
public function testHandlePageContainsRedirect( $xml, $redirectTitle ) {
- $source = $this->getInputStreamSource( $xml );
+ $source = $this->getDataSource( $xml );
$redirect = null;
$callback = function ( Title $title, ForeignTitle $foreignTitle, $revCount,
}
};
- $importer = new WikiImporter( $source, ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
+ $importer = new WikiImporter(
+ $source,
+ ConfigFactory::getDefaultInstance()->makeConfig( 'main' )
+ );
$importer->setPageOutCallback( $callback );
$importer->doImport();
}
public function getRedirectXML() {
+ // @codingStandardsIgnoreStart Generic.Files.LineLength
return array(
array(
<<< EOF
null
),
);
+ // @codingStandardsIgnoreEnd
}
/**
* @param array|null $namespaces
*/
public function testSiteInfoContainsNamespaces( $xml, $namespaces ) {
- $source = $this->getInputStreamSource( $xml );
+ $source = $this->getDataSource( $xml );
$importNamespaces = null;
$callback = function ( array $siteinfo, $innerImporter ) use ( &$importNamespaces ) {
$importNamespaces = $siteinfo['_namespaces'];
};
- $importer = new WikiImporter( $source, ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
+ $importer = new WikiImporter(
+ $source,
+ ConfigFactory::getDefaultInstance()->makeConfig( 'main' )
+ );
$importer->setSiteInfoCallback( $callback );
$importer->doImport();
}
public function getSiteInfoXML() {
+ // @codingStandardsIgnoreStart Generic.Files.LineLength
return array(
array(
<<< EOF
)
),
);
+ // @codingStandardsIgnoreEnd
}
}