2015-02-12 00:24:23 +00:00
|
|
|
<?php
|
2019-05-28 14:04:23 +00:00
|
|
|
|
2024-02-08 14:56:54 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2023-12-11 14:59:55 +00:00
|
|
|
use MediaWiki\Title\Title;
|
|
|
|
|
|
2015-02-12 00:24:23 +00:00
|
|
|
/**
|
|
|
|
|
* Integration test that checks import success and
|
|
|
|
|
* LinkCache integration.
|
|
|
|
|
*
|
2018-03-29 19:53:10 +00:00
|
|
|
* @group large
|
2015-02-12 00:24:23 +00:00
|
|
|
* @group Database
|
2024-02-16 18:04:47 +00:00
|
|
|
* @covers \ImportStreamSource
|
|
|
|
|
* @covers \ImportReporter
|
2015-02-12 00:24:23 +00:00
|
|
|
*
|
|
|
|
|
* @author mwjames
|
|
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class ImportLinkCacheIntegrationTest extends MediaWikiIntegrationTestCase {
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
private $importStreamSource;
|
|
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
protected function setUp(): void {
|
2015-02-12 00:24:23 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2016-01-04 09:59:29 +00:00
|
|
|
$file = dirname( __DIR__ ) . '/../data/import/ImportLinkCacheIntegrationTest.xml';
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
$this->importStreamSource = ImportStreamSource::newFromFile( $file );
|
|
|
|
|
|
|
|
|
|
if ( !$this->importStreamSource->isGood() ) {
|
2023-10-16 15:31:09 +00:00
|
|
|
$this->fail( "Import source for {$file} failed" );
|
2015-02-12 00:24:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testImportForImportSource() {
|
|
|
|
|
$this->doImport( $this->importStreamSource );
|
|
|
|
|
|
|
|
|
|
// Imported title
|
2022-07-05 22:21:30 +00:00
|
|
|
$loremIpsum = Title::makeTitle( NS_MAIN, 'Lorem ipsum' );
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
|
$loremIpsum->getArticleID(),
|
2024-01-25 14:58:57 +00:00
|
|
|
$loremIpsum->getArticleID( IDBAccessObject::READ_LATEST )
|
2015-02-12 00:24:23 +00:00
|
|
|
);
|
|
|
|
|
|
2022-07-05 22:21:30 +00:00
|
|
|
$categoryLoremIpsum = Title::makeTitle( NS_CATEGORY, 'Lorem ipsum' );
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
|
$categoryLoremIpsum->getArticleID(),
|
2024-01-25 14:58:57 +00:00
|
|
|
$categoryLoremIpsum->getArticleID( IDBAccessObject::READ_LATEST )
|
2015-02-12 00:24:23 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @depends testImportForImportSource
|
|
|
|
|
*/
|
|
|
|
|
public function testReImportForImportSource() {
|
|
|
|
|
$this->doImport( $this->importStreamSource );
|
|
|
|
|
|
|
|
|
|
// ReImported title
|
2022-07-05 22:21:30 +00:00
|
|
|
$loremIpsum = Title::makeTitle( NS_MAIN, 'Lorem ipsum' );
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
|
$loremIpsum->getArticleID(),
|
2024-01-25 14:58:57 +00:00
|
|
|
$loremIpsum->getArticleID( IDBAccessObject::READ_LATEST )
|
2015-02-12 00:24:23 +00:00
|
|
|
);
|
|
|
|
|
|
2022-07-05 22:21:30 +00:00
|
|
|
$categoryLoremIpsum = Title::makeTitle( NS_CATEGORY, 'Lorem ipsum' );
|
2015-02-12 00:24:23 +00:00
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
|
$categoryLoremIpsum->getArticleID(),
|
2024-01-25 14:58:57 +00:00
|
|
|
$categoryLoremIpsum->getArticleID( IDBAccessObject::READ_LATEST )
|
2015-02-12 00:24:23 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function doImport( $importStreamSource ) {
|
2021-05-14 23:16:34 +00:00
|
|
|
$importer = $this->getServiceContainer()
|
|
|
|
|
->getWikiImporterFactory()
|
2023-12-08 21:07:22 +00:00
|
|
|
->getWikiImporter( $importStreamSource->value, $this->getTestSysop()->getAuthority() );
|
2015-02-12 00:24:23 +00:00
|
|
|
$importer->setDebug( true );
|
|
|
|
|
|
|
|
|
|
$reporter = new ImportReporter(
|
|
|
|
|
$importer,
|
|
|
|
|
false,
|
|
|
|
|
'',
|
2023-12-08 19:57:57 +00:00
|
|
|
false,
|
|
|
|
|
new RequestContext()
|
2015-02-12 00:24:23 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$reporter->open();
|
2018-03-13 19:32:18 +00:00
|
|
|
$importer->doImport();
|
2023-10-04 09:31:23 +00:00
|
|
|
$this->assertStatusGood( $reporter->close() );
|
2015-02-12 00:24:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|