15 $this->mConf->suffixes = [
'wikipedia' =>
'wiki' ];
16 $this->mConf->wikis = [
'enwiki',
'dewiki',
'frwiki' ];
17 $this->mConf->settings = [
27 'default' =>
'default',
33 'default' =>
'$lang $site $wiki',
62 'default' =>
'default',
76 $GLOBALS[
'global'] = [
'global' =>
'global' ];
85 foreach ( $conf->suffixes as $suffix ) {
86 if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
88 $lang = substr( $wiki, 0, -strlen( $suffix ) );
110 [
'wikipedia',
'en' ],
111 $this->mConf->siteFromDB(
'enwiki' ),
116 $this->mConf->siteFromDB(
'wiki' ),
117 'siteFromDB() on a suffix'
121 $this->mConf->siteFromDB(
'wikien' ),
122 'siteFromDB() on a non-existing wiki'
125 $this->mConf->suffixes = [
'wiki',
'' ];
128 $this->mConf->siteFromDB(
'wikien' ),
129 'siteFromDB() on a non-existing wiki (2)'
138 [
'enwiki',
'dewiki',
'frwiki' ],
139 $this->mConf->getLocalDatabases(),
140 'getLocalDatabases()'
150 $this->mConf->get(
'simple',
'enwiki',
'wiki' ),
151 'get(): simple setting on an existing wiki'
155 $this->mConf->get(
'simple',
'dewiki',
'wiki' ),
156 'get(): simple setting on an existing wiki (2)'
160 $this->mConf->get(
'simple',
'frwiki',
'wiki' ),
161 'get(): simple setting on an existing wiki (3)'
165 $this->mConf->get(
'simple',
'wiki',
'wiki' ),
166 'get(): simple setting on an suffix'
170 $this->mConf->get(
'simple',
'eswiki',
'wiki' ),
171 'get(): simple setting on an non-existing wiki'
176 $this->mConf->get(
'fallback',
'enwiki',
'wiki' ),
177 'get(): fallback setting on an existing wiki'
181 $this->mConf->get(
'fallback',
'dewiki',
'wiki', [], [
'tag' ] ),
182 'get(): fallback setting on an existing wiki (with wiki tag)'
186 $this->mConf->get(
'fallback',
'wiki',
'wiki' ),
187 'get(): fallback setting on an suffix'
191 $this->mConf->get(
'fallback',
'wiki',
'wiki', [], [
'tag' ] ),
192 'get(): fallback setting on an suffix (with wiki tag)'
196 $this->mConf->get(
'fallback',
'eswiki',
'wiki' ),
197 'get(): fallback setting on an non-existing wiki'
201 $this->mConf->get(
'fallback',
'eswiki',
'wiki', [], [
'tag' ] ),
202 'get(): fallback setting on an non-existing wiki (with wiki tag)'
205 $common = [
'wiki' =>
'wiki',
'default' =>
'default' ];
206 $commonTag = [
'tag' =>
'tag',
'wiki' =>
'wiki',
'default' =>
'default' ];
208 [
'enwiki' =>
'enwiki' ] + $common,
209 $this->mConf->get(
'merge',
'enwiki',
'wiki' ),
210 'get(): merging setting on an existing wiki'
213 [
'enwiki' =>
'enwiki' ] + $commonTag,
214 $this->mConf->get(
'merge',
'enwiki',
'wiki', [], [
'tag' ] ),
215 'get(): merging setting on an existing wiki (with tag)'
218 [
'dewiki' =>
'dewiki' ] + $common,
219 $this->mConf->get(
'merge',
'dewiki',
'wiki' ),
220 'get(): merging setting on an existing wiki (2)'
223 [
'dewiki' =>
'dewiki' ] + $commonTag,
224 $this->mConf->get(
'merge',
'dewiki',
'wiki', [], [
'tag' ] ),
225 'get(): merging setting on an existing wiki (2) (with tag)'
228 [
'frwiki' =>
'frwiki' ] + $common,
229 $this->mConf->get(
'merge',
'frwiki',
'wiki' ),
230 'get(): merging setting on an existing wiki (3)'
233 [
'frwiki' =>
'frwiki' ] + $commonTag,
234 $this->mConf->get(
'merge',
'frwiki',
'wiki', [], [
'tag' ] ),
235 'get(): merging setting on an existing wiki (3) (with tag)'
238 [
'wiki' =>
'wiki' ] + $common,
239 $this->mConf->get(
'merge',
'wiki',
'wiki' ),
240 'get(): merging setting on an suffix'
243 [
'wiki' =>
'wiki' ] + $commonTag,
244 $this->mConf->get(
'merge',
'wiki',
'wiki', [], [
'tag' ] ),
245 'get(): merging setting on an suffix (with tag)'
249 $this->mConf->get(
'merge',
'eswiki',
'wiki' ),
250 'get(): merging setting on an non-existing wiki'
254 $this->mConf->get(
'merge',
'eswiki',
'wiki', [], [
'tag' ] ),
255 'get(): merging setting on an non-existing wiki (with tag)'
263 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
267 $this->mConf->siteFromDB(
'enwiki' ),
268 'siteFromDB() with callback'
272 $this->mConf->siteFromDB(
'wiki' ),
273 'siteFromDB() with callback on a suffix'
277 $this->mConf->siteFromDB(
'wikien' ),
278 'siteFromDB() with callback on a non-existing wiki'
286 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
290 $this->mConf->get(
'params',
'enwiki',
'wiki' ),
291 'get(): parameter replacement on an existing wiki'
295 $this->mConf->get(
'params',
'dewiki',
'wiki' ),
296 'get(): parameter replacement on an existing wiki (2)'
300 $this->mConf->get(
'params',
'frwiki',
'wiki' ),
301 'get(): parameter replacement on an existing wiki (3)'
305 $this->mConf->get(
'params',
'wiki',
'wiki' ),
306 'get(): parameter replacement on an suffix'
310 $this->mConf->get(
'params',
'eswiki',
'wiki' ),
311 'get(): parameter replacement on an non-existing wiki'
319 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
322 'simple' =>
'enwiki',
324 'params' =>
'en wiki enwiki',
325 'global' => [
'enwiki' =>
'enwiki' ] +
$GLOBALS[
'global'],
327 'enwiki' =>
'enwiki',
330 'default' =>
'default'
333 $this->assertEquals( $getall, $this->mConf->getAll(
'enwiki' ),
'getAll()' );
335 $this->mConf->extractAllGlobals(
'enwiki',
'wiki' );
340 'extractAllGlobals(): simple setting'
345 'extractAllGlobals(): fallback setting'
350 'extractAllGlobals(): parameter replacement'
355 'extractAllGlobals(): merging with global'
360 'extractAllGlobals(): merging setting'
testGetAllGlobals()
SiteConfiguration::getAll.
testSiteFromDbWithCallback()
SiteConfiguration::siteFromDB.
testParameterReplacement()
SiteConfiguration::get.
testGetLocalDatabases()
SiteConfiguration::getLocalDatabases.
testSiteFromDb()
SiteConfiguration::siteFromDB.
static getSiteParamsCallback( $conf, $wiki)
This function is used as a callback within the tests below.
testGetConfVariables()
SiteConfiguration::get.
This is a class for holding configuration settings, particularly for multi-wiki sites.
if(!isset( $args[0])) $lang