2 use MediaWiki\MediaWikiServices
;
5 * Integration test that checks import success and
6 * LinkCache integration.
13 class ImportLinkCacheIntegrationTest
extends MediaWikiTestCase
{
15 private $importStreamSource;
17 protected function setUp() {
20 $file = dirname( __DIR__
) . '/../data/import/ImportLinkCacheIntegrationTest.xml';
22 $this->importStreamSource
= ImportStreamSource
::newFromFile( $file );
24 if ( !$this->importStreamSource
->isGood() ) {
25 throw new Exception( "Import source for {$file} failed" );
29 public function testImportForImportSource() {
30 $this->doImport( $this->importStreamSource
);
33 $loremIpsum = Title
::newFromText( 'Lorem ipsum' );
36 $loremIpsum->getArticleID(),
37 $loremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
40 $categoryLoremIpsum = Title
::newFromText( 'Category:Lorem ipsum' );
43 $categoryLoremIpsum->getArticleID(),
44 $categoryLoremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
47 $page = new WikiPage( $loremIpsum );
48 $page->doDeleteArticle( 'import test: delete page' );
50 $page = new WikiPage( $categoryLoremIpsum );
51 $page->doDeleteArticle( 'import test: delete page' );
55 * @depends testImportForImportSource
57 public function testReImportForImportSource() {
58 $this->doImport( $this->importStreamSource
);
61 $loremIpsum = Title
::newFromText( 'Lorem ipsum' );
64 $loremIpsum->getArticleID(),
65 $loremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
68 $categoryLoremIpsum = Title
::newFromText( 'Category:Lorem ipsum' );
71 $categoryLoremIpsum->getArticleID(),
72 $categoryLoremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
76 private function doImport( $importStreamSource ) {
77 $importer = new WikiImporter(
78 $importStreamSource->value
,
79 MediaWikiServices
::getInstance()->getMainConfig()
81 $importer->setDebug( true );
83 $reporter = new ImportReporter(
90 $reporter->setContext( new RequestContext() );
95 $importer->doImport();
96 } catch ( Exception
$e ) {
100 $result = $reporter->close();