public function getAllowedParams() { $modules = $this->getMain()->getModuleManager()->getNames('action'); sort($modules); $querymodules = $this->queryObj->getModuleManager()->getNames(); sort($querymodules); $formatmodules = $this->getMain()->getModuleManager()->getNames('format'); sort($formatmodules); return array('modules' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $modules), 'querymodules' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $querymodules), 'mainmodule' => false, 'pagesetmodule' => false, 'formatmodules' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $formatmodules)); }
/** * 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(['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)'); } }
/** * @param $type string * @return array */ private function getQueryModules($type) { $options = array(); $modules = $this->apiQuery->getModuleManager()->getNames($type); sort($modules); foreach ($modules as $module) { $options["{$type}={$module}"] = "{$type}={$module}"; } // Give grep a chance to find the usages: // apisb-query-prop, apisb-query-list, apisb-query-meta $optgroup = array(); $optgroup[$this->msg("apisb-query-{$type}")->parse()] = $options; return $optgroup; }
public function testPrefixes() { $main = new ApiMain(new FauxRequest()); $query = new ApiQuery($main, 'foo', 'bar'); $modules = $query->getModuleManager()->getNamesWithClasses(); $prefixes = array(); foreach ($modules as $name => $class) { $module = new $class($main, $name); $prefix = $module->getModulePrefix(); if (isset($prefixes[$prefix])) { $this->fail("Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}"); } $prefixes[$module->getModulePrefix()] = $class; } $this->assertTrue(true); // dummy call to make this test non-incomplete }