<?php
+use Wikimedia\TestingAccessWrapper;
+
/**
* Checks that all API modules, core and extensions, have documentation i18n messages
*
private static $main;
/** @var array Sets of globals to test. Each array element is input to HashConfig */
- private static $testGlobals = array(
- array(
+ private static $testGlobals = [
+ [
'MiserMode' => false,
'AllowCategorizedRecentChanges' => false,
- ),
- array(
+ ],
+ [
'MiserMode' => true,
'AllowCategorizedRecentChanges' => true,
- ),
- );
+ ],
+ ];
/**
* Initialize/fetch the ApiMain instance for testing
$main = self::getMain();
// Set configuration variables
- $main->getContext()->setConfig( new MultiConfig( array(
+ $main->getContext()->setConfig( new MultiConfig( [
new HashConfig( $globals ),
RequestContext::getMain()->getConfig(),
- ) ) );
+ ] ) );
foreach ( $globals as $k => $v ) {
- $this->setMWGlobals( "wg$k", $v );
+ $this->setMwGlobals( "wg$k", $v );
}
// Fetch module.
}
// Module description messages.
- $this->checkMessage( $module->getDescriptionMessage(), 'Module description' );
+ $this->checkMessage( $module->getSummaryMessage(), 'Module summary' );
+ $this->checkMessage( $module->getExtendedDescription(), 'Module help top text' );
// Parameters. Lots of messages in here.
$params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
- $tags = array();
+ $tags = [];
foreach ( $params as $name => $settings ) {
if ( !is_array( $settings ) ) {
- $settings = array();
+ $settings = [];
}
// Basic description message
// Messages for examples.
foreach ( $module->getExamplesMessages() as $qs => $msg ) {
+ $this->assertStringStartsNotWith( 'api.php?', $qs,
+ "Query string must not begin with 'api.php?'" );
$this->checkMessage( $msg, "Example $qs" );
}
}
$paths = self::getSubModulePaths( $main->getModuleManager() );
array_unshift( $paths, $main->getModulePath() );
- $ret = array();
+ $ret = [];
foreach ( $paths as $path ) {
foreach ( self::$testGlobals as $globals ) {
- $g = array();
+ $g = [];
foreach ( $globals as $k => $v ) {
$g[] = "$k=" . var_export( $v, 1 );
}
- $k = "Module $path with " . join( ', ', $g );
- $ret[$k] = array( $path, $globals );
+ $k = "Module $path with " . implode( ', ', $g );
+ $ret[$k] = [ $path, $globals ];
}
}
return $ret;
* @return string[]
*/
protected static function getSubModulePaths( ApiModuleManager $manager ) {
- $paths = array();
+ $paths = [];
foreach ( $manager->getNames() as $name ) {
$module = $manager->getModule( $name );
$paths[] = $module->getModulePath();