X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FImportTest.php;h=7ef44e790bb90073b760dbbf1548f5e4e4cb5799;hb=725a203bc1f35a5cd7624d4f1a116fb46667ca2d;hp=678c89bfa99b54e1dd4f17bc68f489eff644ae62;hpb=30e009794bacc2e3138c372e6ddf876dca2d4a9c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/ImportTest.php b/tests/phpunit/includes/ImportTest.php index 678c89bfa9..7ef44e790b 100644 --- a/tests/phpunit/includes/ImportTest.php +++ b/tests/phpunit/includes/ImportTest.php @@ -10,6 +10,9 @@ class ImportTest extends MediaWikiLangTestCase { private function getInputStreamSource( $xml ) { + if ( ini_get( 'allow_url_fopen' ) != 1 ) { + $this->markTestSkipped( 'bug 73283: this test needs allow_url_fopen to be enabled' ); + } $file = 'data:application/xml,' . $xml; $status = ImportStreamSource::newFromFile( $file ); if ( !$status->isGood() ) { @@ -28,7 +31,8 @@ class ImportTest extends MediaWikiLangTestCase { $source = $this->getInputStreamSource( $xml ); $redirect = null; - $callback = function ( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) use ( &$redirect ) { + $callback = function ( Title $title, ForeignTitle $foreignTitle, $revCount, + $sRevCount, $pageInfo ) use ( &$redirect ) { if ( array_key_exists( 'redirect', $pageInfo ) ) { $redirect = $pageInfo['redirect']; } @@ -98,4 +102,59 @@ EOF ); } + /** + * @covers WikiImporter::handleSiteInfo + * @dataProvider getSiteInfoXML + * @param string $xml + * @param array|null $namespaces + */ + public function testSiteInfoContainsNamespaces( $xml, $namespaces ) { + $source = $this->getInputStreamSource( $xml ); + + $importNamespaces = null; + $callback = function ( array $siteinfo, $innerImporter ) use ( &$importNamespaces ) { + $importNamespaces = $siteinfo['_namespaces']; + }; + + $importer = new WikiImporter( $source, ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) ); + $importer->setSiteInfoCallback( $callback ); + $importer->doImport(); + + $this->assertEquals( $importNamespaces, $namespaces ); + } + + public function getSiteInfoXML() { + return array( + array( + <<< EOF + + + + Media + Special + + Talk + User + User talk + Portal + Portal talk + + + +EOF + , + array( + '-2' => 'Media', + '-1' => 'Special', + '0' => '', + '1' => 'Talk', + '2' => 'User', + '3' => 'User talk', + '100' => 'Portal', + '101' => 'Portal talk', + ) + ), + ); + } + }