MediaWiki
REL1_32
ApiPrefixUniquenessTest.php
Go to the documentation of this file.
1
<?php
2
9
class
ApiPrefixUniquenessTest
extends
MediaWikiTestCase
{
10
11
public
function
testPrefixes
() {
12
$main =
new
ApiMain
(
new
FauxRequest
() );
13
$query
=
new
ApiQuery
( $main,
'foo'
);
14
$moduleManager =
$query
->getModuleManager();
15
16
$modules
= $moduleManager->getNames();
17
$prefixes = [];
18
19
foreach
(
$modules
as $name ) {
20
$module = $moduleManager->getModule( $name );
21
$class = get_class( $module );
22
23
$prefix = $module->getModulePrefix();
24
if
( $prefix ===
''
/* HACK: T196962 */
|| $prefix ===
'wbeu'
) {
25
continue
;
26
}
27
28
if
( isset( $prefixes[$prefix] ) ) {
29
$this->fail(
30
"Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}"
31
);
32
}
33
$prefixes[$module->getModulePrefix()] = $class;
34
35
if
( $module instanceof
ApiQueryGeneratorBase
) {
36
// namespace with 'g', a generator can share a prefix with a module
37
$prefix =
'g'
. $prefix;
38
if
( isset( $prefixes[$prefix] ) ) {
39
$this->fail(
40
"Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}"
.
41
" (as a generator)"
42
);
43
}
44
$prefixes[$module->getModulePrefix()] = $class;
45
}
46
}
47
$this->assertTrue(
true
);
// dummy call to make this test non-incomplete
48
}
49
}
$modules
$modules
Definition
HTMLFormElement.php:12
ApiMain
This is the main API class, used for both external and internal processing.
Definition
ApiMain.php:41
ApiPrefixUniquenessTest
Checks that all API query modules, core and extensions, have unique prefixes.
Definition
ApiPrefixUniquenessTest.php:9
ApiPrefixUniquenessTest\testPrefixes
testPrefixes()
Definition
ApiPrefixUniquenessTest.php:11
ApiQueryGeneratorBase
Definition
ApiQueryGeneratorBase.php:26
ApiQuery
This is the main query class.
Definition
ApiQuery.php:36
FauxRequest
WebRequest clone which takes values from a provided array.
Definition
FauxRequest.php:33
MediaWikiTestCase
Definition
MediaWikiTestCase.php:16
$query
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition
hooks.txt:1656
tests
phpunit
structure
ApiPrefixUniquenessTest.php
Generated on Mon Nov 25 2024 15:59:05 for MediaWiki by
1.10.0