3 * Integration test that checks import success and
4 * LinkCache integration.
11 class ImportLinkCacheIntegrationTest
extends MediaWikiTestCase
{
13 private $importStreamSource;
15 protected function setUp() {
18 $file = dirname( __DIR__
) . '/data/import/ImportLinkCacheIntegrationTest.xml';
20 $this->importStreamSource
= ImportStreamSource
::newFromFile( $file );
22 if ( !$this->importStreamSource
->isGood() ) {
23 throw new Exception( "Import source for {$file} failed" );
27 public function testImportForImportSource() {
29 $this->doImport( $this->importStreamSource
);
32 $loremIpsum = Title
::newFromText( 'Lorem ipsum' );
35 $loremIpsum->getArticleID(),
36 $loremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
39 $categoryLoremIpsum = Title
::newFromText( 'Category:Lorem ipsum' );
42 $categoryLoremIpsum->getArticleID(),
43 $categoryLoremIpsum->getArticleID( Title
::GAID_FOR_UPDATE
)
46 $page = new WikiPage( $loremIpsum );
47 $page->doDeleteArticle( 'import test: delete page' );
49 $page = new WikiPage( $categoryLoremIpsum );
50 $page->doDeleteArticle( 'import test: delete page' );
54 * @depends testImportForImportSource
56 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 ) {
78 $importer = new WikiImporter(
79 $importStreamSource->value
,
80 ConfigFactory
::getDefaultInstance()->makeConfig( 'main' )
82 $importer->setDebug( true );
84 $reporter = new ImportReporter(
91 $reporter->setContext( new RequestContext() );
96 $importer->doImport();
97 } catch ( Exception
$e ) {
101 $result = $reporter->close();