summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/query/ApiQueryTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/api/query/ApiQueryTest.php')
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryTest.php56
1 files changed, 34 insertions, 22 deletions
diff --git a/tests/phpunit/includes/api/query/ApiQueryTest.php b/tests/phpunit/includes/api/query/ApiQueryTest.php
index bba22c77..5f061b50 100644
--- a/tests/phpunit/includes/api/query/ApiQueryTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryTest.php
@@ -7,32 +7,21 @@
* @covers ApiQuery
*/
class ApiQueryTest extends ApiTestCase {
- /**
- * @var array Storage for $wgHooks
- */
- protected $hooks;
-
protected function setUp() {
- global $wgHooks;
-
parent::setUp();
$this->doLogin();
- // Setup en: as interwiki prefix
- $this->hooks = $wgHooks;
- $wgHooks['InterwikiLoadPrefix'][] = function ( $prefix, &$data ) {
- if ( $prefix == 'apiquerytestiw' ) {
- $data = array( 'iw_url' => 'wikipedia' );
- }
- return false;
- };
- }
-
- protected function tearDown() {
- global $wgHooks;
- $wgHooks = $this->hooks;
-
- parent::tearDown();
+ // Setup apiquerytestiw: as interwiki prefix
+ $this->setMwGlobals( 'wgHooks', array(
+ 'InterwikiLoadPrefix' => array(
+ function ( $prefix, &$data ) {
+ if ( $prefix == 'apiquerytestiw' ) {
+ $data = array( 'iw_url' => 'wikipedia' );
+ }
+ return false;
+ }
+ )
+ ) );
}
public function testTitlesGetNormalized() {
@@ -127,4 +116,27 @@ class ApiQueryTest extends ApiTestCase {
array( 'apiquerytestiw:foo', NS_MAIN, null, true ),
);
}
+
+ /**
+ * Test if all classes in the query module manager exists
+ */
+ public function testClassNamesInModuleManager() {
+ global $wgAutoloadLocalClasses, $wgAutoloadClasses;
+
+ // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php
+ $classes = $wgAutoloadLocalClasses + $wgAutoloadClasses;
+
+ $api = new ApiMain(
+ new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) )
+ );
+ $queryApi = new ApiQuery( $api, 'query' );
+ $modules = $queryApi->getModuleManager()->getNamesWithClasses();
+ foreach( $modules as $name => $class ) {
+ $this->assertArrayHasKey(
+ $class,
+ $classes,
+ 'Class ' . $class . ' for api module ' . $name . ' not in autoloader (with exact case)'
+ );
+ }
+ }
}