MediaWiki REL1_31
ImportLinkCacheIntegrationTest.php
Go to the documentation of this file.
1<?php
3
16
18
19 protected function setUp() {
20 parent::setUp();
21
22 $file = dirname( __DIR__ ) . '/../data/import/ImportLinkCacheIntegrationTest.xml';
23
24 $this->importStreamSource = ImportStreamSource::newFromFile( $file );
25
26 if ( !$this->importStreamSource->isGood() ) {
27 throw new Exception( "Import source for {$file} failed" );
28 }
29 }
30
31 public function testImportForImportSource() {
32 $this->doImport( $this->importStreamSource );
33
34 // Imported title
35 $loremIpsum = Title::newFromText( 'Lorem ipsum' );
36
37 $this->assertSame(
38 $loremIpsum->getArticleID(),
39 $loremIpsum->getArticleID( Title::GAID_FOR_UPDATE )
40 );
41
42 $categoryLoremIpsum = Title::newFromText( 'Category:Lorem ipsum' );
43
44 $this->assertSame(
45 $categoryLoremIpsum->getArticleID(),
46 $categoryLoremIpsum->getArticleID( Title::GAID_FOR_UPDATE )
47 );
48
49 $page = new WikiPage( $loremIpsum );
50 $page->doDeleteArticle( 'import test: delete page' );
51
52 $page = new WikiPage( $categoryLoremIpsum );
53 $page->doDeleteArticle( 'import test: delete page' );
54 }
55
59 public function testReImportForImportSource() {
60 $this->doImport( $this->importStreamSource );
61
62 // ReImported title
63 $loremIpsum = Title::newFromText( 'Lorem ipsum' );
64
65 $this->assertSame(
66 $loremIpsum->getArticleID(),
67 $loremIpsum->getArticleID( Title::GAID_FOR_UPDATE )
68 );
69
70 $categoryLoremIpsum = Title::newFromText( 'Category:Lorem ipsum' );
71
72 $this->assertSame(
73 $categoryLoremIpsum->getArticleID(),
74 $categoryLoremIpsum->getArticleID( Title::GAID_FOR_UPDATE )
75 );
76 }
77
78 private function doImport( $importStreamSource ) {
79 $importer = new WikiImporter(
81 MediaWikiServices::getInstance()->getMainConfig()
82 );
83 $importer->setDebug( true );
84
85 $reporter = new ImportReporter(
86 $importer,
87 false,
88 '',
89 false
90 );
91
92 $reporter->setContext( new RequestContext() );
93 $reporter->open();
94
95 $importer->doImport();
96
97 $result = $reporter->close();
98
99 $this->assertTrue(
100 $result->isGood()
101 );
102 }
103
104}
Integration test that checks import success and LinkCache integration.
testReImportForImportSource()
@depends testImportForImportSource
Reporting callback.
static newFromFile( $filename)
MediaWikiServices is the service locator for the application scope of MediaWiki.
Group all the pieces relevant to the context of a request into one instance.
XML file reader for the page data importer.
Class representing a MediaWiki article and history.
Definition WikiPage.php:37