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() {
31 $this->doImport( $this->importStreamSource
);
34 $loremIpsum = Title
::newFromText( 'Lorem ipsum' );
37 $loremIpsum->getArticleID(),
38 $loremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
41 $categoryLoremIpsum = Title
::newFromText( 'Category:Lorem ipsum' );
44 $categoryLoremIpsum->getArticleID(),
45 $categoryLoremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
48 $page = new WikiPage( $loremIpsum );
49 $page->doDeleteArticle( 'import test: delete page' );
51 $page = new WikiPage( $categoryLoremIpsum );
52 $page->doDeleteArticle( 'import test: delete page' );
56 * @depends testImportForImportSource
58 public function testReImportForImportSource() {
60 $this->doImport( $this->importStreamSource
);
63 $loremIpsum = Title
::newFromText( 'Lorem ipsum' );
66 $loremIpsum->getArticleID(),
67 $loremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
70 $categoryLoremIpsum = Title
::newFromText( 'Category:Lorem ipsum' );
73 $categoryLoremIpsum->getArticleID(),
74 $categoryLoremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
78 private function doImport( $importStreamSource ) {
80 $importer = new WikiImporter(
81 $importStreamSource->value
,
82 MediaWikiServices
::getInstance()->getMainConfig()
84 $importer->setDebug( true );
86 $reporter = new ImportReporter(
93 $reporter->setContext( new RequestContext() );
98 $importer->doImport();
99 } catch ( Exception
$e ) {
103 $result = $reporter->close();