MediaWiki REL1_32
ApiPrefixUniquenessTest.php
Go to the documentation of this file.
1<?php
2
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}
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:41
Checks that all API query modules, core and extensions, have unique prefixes.
This is the main query class.
Definition ApiQuery.php:36
WebRequest clone which takes values from a provided array.
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