MediaWiki
REL1_31
ImportLinkCacheIntegrationTest.php
Go to the documentation of this file.
1
<?php
2
use
MediaWiki\MediaWikiServices
;
3
15
class
ImportLinkCacheIntegrationTest
extends
MediaWikiTestCase
{
16
17
private
$importStreamSource
;
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
(
80
$importStreamSource
->value,
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
}
ImportLinkCacheIntegrationTest
Integration test that checks import success and LinkCache integration.
Definition
ImportLinkCacheIntegrationTest.php:15
ImportLinkCacheIntegrationTest\doImport
doImport( $importStreamSource)
Definition
ImportLinkCacheIntegrationTest.php:78
ImportLinkCacheIntegrationTest\$importStreamSource
$importStreamSource
Definition
ImportLinkCacheIntegrationTest.php:17
ImportLinkCacheIntegrationTest\testReImportForImportSource
testReImportForImportSource()
@depends testImportForImportSource
Definition
ImportLinkCacheIntegrationTest.php:59
ImportLinkCacheIntegrationTest\setUp
setUp()
Definition
ImportLinkCacheIntegrationTest.php:19
ImportLinkCacheIntegrationTest\testImportForImportSource
testImportForImportSource()
Definition
ImportLinkCacheIntegrationTest.php:31
ImportReporter
Reporting callback.
Definition
ImportReporter.php:27
ImportStreamSource\newFromFile
static newFromFile( $filename)
Definition
ImportStreamSource.php:55
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:88
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:32
WikiImporter
XML file reader for the page data importer.
Definition
WikiImporter.php:33
WikiPage
Class representing a MediaWiki article and history.
Definition
WikiPage.php:37
tests
phpunit
includes
import
ImportLinkCacheIntegrationTest.php
Generated on Mon Nov 25 2024 15:36:23 for MediaWiki by
1.10.0