MediaWiki
REL1_30
SitesCacheFileBuilderTest.php
Go to the documentation of this file.
1
<?php
2
30
class
SitesCacheFileBuilderTest
extends
PHPUnit_Framework_TestCase {
31
32
protected
function
setUp
() {
33
$this->cacheFile = $this->
getCacheFile
();
34
}
35
36
protected
function
tearDown
() {
37
unlink( $this->cacheFile );
38
}
39
40
public
function
testBuild
() {
41
$cacheBuilder = $this->
newSitesCacheFileBuilder
( $this->
getSites
() );
42
$cacheBuilder->build();
43
44
$contents = file_get_contents( $this->cacheFile );
45
$this->assertEquals( json_encode( $this->
getExpectedData
() ), $contents );
46
}
47
48
private
function
getExpectedData
() {
49
return
[
50
'sites'
=> [
51
'foobar'
=> [
52
'globalid'
=>
'foobar'
,
53
'type'
=>
'unknown'
,
54
'group'
=>
'none'
,
55
'source'
=>
'local'
,
56
'language'
=>
null
,
57
'localids'
=> [],
58
'config'
=> [],
59
'data'
=> [],
60
'forward'
=>
false
,
61
'internalid'
=>
null
,
62
'identifiers'
=> []
63
],
64
'enwiktionary'
=> [
65
'globalid'
=>
'enwiktionary'
,
66
'type'
=>
'mediawiki'
,
67
'group'
=>
'wiktionary'
,
68
'source'
=>
'local'
,
69
'language'
=>
'en'
,
70
'localids'
=> [
71
'equivalent'
=> [
'enwiktionary'
]
72
],
73
'config'
=> [],
74
'data'
=> [
75
'paths'
=> [
76
'page_path'
=>
'https://en.wiktionary.org/wiki/$1'
,
77
'file_path'
=>
'https://en.wiktionary.org/w/$1'
78
]
79
],
80
'forward'
=>
false
,
81
'internalid'
=>
null
,
82
'identifiers'
=> [
83
[
84
'type'
=>
'equivalent'
,
85
'key'
=>
'enwiktionary'
86
]
87
]
88
]
89
]
90
];
91
}
92
93
private
function
newSitesCacheFileBuilder
(
SiteList
$sites ) {
94
return
new
SitesCacheFileBuilder
(
95
$this->
getSiteLookup
( $sites ),
96
$this->cacheFile
97
);
98
}
99
100
private
function
getSiteLookup
(
SiteList
$sites ) {
101
$siteLookup = $this->getMockBuilder(
'SiteLookup'
)
102
->disableOriginalConstructor()
103
->getMock();
104
105
$siteLookup->expects( $this->
any
() )
106
->method(
'getSites'
)
107
->will( $this->returnValue( $sites ) );
108
109
return
$siteLookup;
110
}
111
112
private
function
getSites
() {
113
$sites = [];
114
115
$site =
new
Site
();
116
$site->setGlobalId(
'foobar'
);
117
$sites[] = $site;
118
119
$site =
new
MediaWikiSite
();
120
$site->setGlobalId(
'enwiktionary'
);
121
$site->setGroup(
'wiktionary'
);
122
$site->setLanguageCode(
'en'
);
123
$site->addNavigationId(
'enwiktionary'
);
124
$site->setPath( MediaWikiSite::PATH_PAGE,
"https://en.wiktionary.org/wiki/$1"
);
125
$site->setPath( MediaWikiSite::PATH_FILE,
"https://en.wiktionary.org/w/$1"
);
126
$sites[] = $site;
127
128
return
new
SiteList
( $sites );
129
}
130
131
private
function
getCacheFile
() {
132
return
tempnam( sys_get_temp_dir(),
'mw-test-sitelist'
);
133
}
134
135
}
any
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Definition
COPYING.txt:326
MediaWikiSite
Class representing a MediaWiki site.
Definition
MediaWikiSite.php:38
SiteList
Definition
SiteList.php:29
Site
Definition
Site.php:29
SitesCacheFileBuilderTest
Definition
SitesCacheFileBuilderTest.php:30
SitesCacheFileBuilderTest\getCacheFile
getCacheFile()
Definition
SitesCacheFileBuilderTest.php:131
SitesCacheFileBuilderTest\testBuild
testBuild()
Definition
SitesCacheFileBuilderTest.php:40
SitesCacheFileBuilderTest\setUp
setUp()
Definition
SitesCacheFileBuilderTest.php:32
SitesCacheFileBuilderTest\getExpectedData
getExpectedData()
Definition
SitesCacheFileBuilderTest.php:48
SitesCacheFileBuilderTest\newSitesCacheFileBuilder
newSitesCacheFileBuilder(SiteList $sites)
Definition
SitesCacheFileBuilderTest.php:93
SitesCacheFileBuilderTest\tearDown
tearDown()
Definition
SitesCacheFileBuilderTest.php:36
SitesCacheFileBuilderTest\getSites
getSites()
Definition
SitesCacheFileBuilderTest.php:112
SitesCacheFileBuilderTest\getSiteLookup
getSiteLookup(SiteList $sites)
Definition
SitesCacheFileBuilderTest.php:100
SitesCacheFileBuilder
Definition
SitesCacheFileBuilder.php:25
tests
phpunit
includes
site
SitesCacheFileBuilderTest.php
Generated on Mon Nov 25 2024 15:43:58 for MediaWiki by
1.10.0