MediaWiki  master
ApiStructureTest Class Reference

Checks that all API modules, core and extensions, conform to the conventions: More...

Inheritance diagram for ApiStructureTest:
Collaboration diagram for ApiStructureTest:

Public Member Functions

 testDocumentationExists ( $path, array $globals)
 provideDocumentationExists More...
 
 testParameterConsistency ( $path)
 provideParameterConsistency More...
 

Static Public Member Functions

static provideDocumentationExists ()
 
static provideParameterConsistency ()
 

Static Protected Member Functions

static getSubModulePaths (ApiModuleManager $manager)
 Return paths of all submodules in an ApiModuleManager, recursively. More...
 

Private Member Functions

 checkMessage ( $msg, $what)
 Test a message. More...
 
 validateDefault ( $param, $config)
 Asserts that $default is a valid default for $type. More...
 
 validateType ( $types, $value, $param, $desc)
 Throws if $value does not match one of the types specified in $types. More...
 

Static Private Member Functions

static getMain ()
 Initialize/fetch the ApiMain instance for testing. More...
 

Static Private Attributes

static $constantNames = null
 
static ApiMain $main
 
static $paramAllowedTypes
 
static $paramProhibitedTypes
 
static $paramRequirements
 
static array static $paramTypes
 Values are an array, where each array value is a permitted type. More...
 
static array $testGlobals
 Sets of globals to test. More...
 

Detailed Description

Checks that all API modules, core and extensions, conform to the conventions:

  • have documentation i18n messages (the test won't catch everything since i18n messages can vary based on the wiki configuration, but it should catch many cases for forgotten i18n)
  • do not have inconsistencies in the parameter definitions

    API

Definition at line 15 of file ApiStructureTest.php.

Member Function Documentation

◆ checkMessage()

ApiStructureTest::checkMessage (   $msg,
  $what 
)
private

Test a message.

Parameters
Message$msg
string$whatWhich message is being checked

Definition at line 126 of file ApiStructureTest.php.

References class, getContext(), and ApiBase\makeMessage().

Referenced by testDocumentationExists().

◆ getMain()

static ApiStructureTest::getMain ( )
staticprivate

Initialize/fetch the ApiMain instance for testing.

Returns
ApiMain

Definition at line 110 of file ApiStructureTest.php.

References RequestContext\getMain(), Title\makeTitle(), and NS_SPECIAL.

◆ getSubModulePaths()

static ApiStructureTest::getSubModulePaths ( ApiModuleManager  $manager)
staticprotected

Return paths of all submodules in an ApiModuleManager, recursively.

Parameters
ApiModuleManager$manager
Returns
string[]

Definition at line 645 of file ApiStructureTest.php.

References $name, as, ApiModuleManager\getModule(), and ApiModuleManager\getNames().

◆ provideDocumentationExists()

static ApiStructureTest::provideDocumentationExists ( )
static

Definition at line 225 of file ApiStructureTest.php.

References $path, $ret, as, ApiMain\getModuleManager(), and ApiBase\getModulePath().

◆ provideParameterConsistency()

static ApiStructureTest::provideParameterConsistency ( )
static
Returns
array List of API module paths to test

Definition at line 628 of file ApiStructureTest.php.

References $path, $ret, as, ApiMain\getModuleManager(), and ApiBase\getModulePath().

◆ testDocumentationExists()

ApiStructureTest::testDocumentationExists (   $path,
array  $globals 
)

◆ testParameterConsistency()

◆ validateDefault()

ApiStructureTest::validateDefault (   $param,
  $config 
)
private

Asserts that $default is a valid default for $type.

Parameters
string$paramName of param, for error messages
array$configArray of configuration options for this parameter

Definition at line 527 of file ApiStructureTest.php.

References $e, $type, as, ApiBase\PARAM_DFLT, ApiBase\PARAM_EXTRA_NAMESPACES, ApiBase\PARAM_ISMULTI, ApiBase\PARAM_TYPE, and wfTimestamp().

Referenced by testParameterConsistency().

◆ validateType()

ApiStructureTest::validateType (   $types,
  $value,
  $param,
  $desc 
)
private

Throws if $value does not match one of the types specified in $types.

Parameters
array$typesFrom self::$paramTypes array
mixed$valueValue to check
string$paramName of param we're checking, for error messages
string$descDescription for error messages

Definition at line 483 of file ApiStructureTest.php.

References $type, $value, and as.

Referenced by testParameterConsistency().

Member Data Documentation

◆ $constantNames

ApiStructureTest::$constantNames = null
staticprivate

Definition at line 104 of file ApiStructureTest.php.

◆ $main

ApiMain ApiStructureTest::$main
staticprivate

Definition at line 18 of file ApiStructureTest.php.

◆ $paramAllowedTypes

ApiStructureTest::$paramAllowedTypes
staticprivate
Initial value:
= [
ApiBase::PARAM_MAX => [ 'integer', 'limit' ]

Definition at line 82 of file ApiStructureTest.php.

◆ $paramProhibitedTypes

ApiStructureTest::$paramProhibitedTypes
staticprivate
Initial value:
= [
ApiBase::PARAM_ISMULTI => [ 'boolean', 'limit', 'upload' ]

Definition at line 98 of file ApiStructureTest.php.

◆ $paramRequirements

◆ $paramTypes

array static ApiStructureTest::$paramTypes
staticprivate
Initial value:
= [
ApiBase::PARAM_ISMULTI => [ 'boolean' ]

Values are an array, where each array value is a permitted type.

A type can be a string, which is the name of an internal type or a class/interface. Or it can be an array, in which case the value must be an array whose elements are the types given in the array (e.g., [ 'string', integer' ] means an array whose entries are strings and/or integers).

Definition at line 38 of file ApiStructureTest.php.

◆ $testGlobals

array ApiStructureTest::$testGlobals
staticprivate
Initial value:
= [
[
'MiserMode' => false,
]

Sets of globals to test.

Each array element is input to HashConfig

Definition at line 21 of file ApiStructureTest.php.


The documentation for this class was generated from the following file: