16 'InterwikiLoadPrefix' => [
17 function ( $prefix, &$data ) {
18 if ( $prefix ==
'apiquerytestiw' ) {
19 $data = [
'iw_url' =>
'wikipedia' ];
31 'wgCapitalLinks' =>
true,
36 'titles' =>
'Project:articleA|article_B' ] );
38 $this->assertArrayHasKey(
'query', $data[0] );
39 $this->assertArrayHasKey(
'normalized', $data[0][
'query'] );
46 'fromencoded' =>
false,
47 'from' =>
'Project:articleA',
48 'to' => $to->getPrefixedText(),
50 $data[0][
'query'][
'normalized'][0]
55 'fromencoded' =>
false,
56 'from' =>
'article_B',
59 $data[0][
'query'][
'normalized'][1]
65 while ( !$title || Title::newFromText( $title )->exists() ) {
66 $title = md5( mt_rand( 0, 100000 ) );
71 'titles' => $title .
'|Talk:' ] );
73 $this->assertArrayHasKey(
'query', $data[0] );
74 $this->assertArrayHasKey(
'pages', $data[0][
'query'] );
75 $this->assertEquals( 2, count( $data[0][
'query'][
'pages'] ) );
77 $this->assertArrayHasKey( -2, $data[0][
'query'][
'pages'] );
78 $this->assertArrayHasKey( -1, $data[0][
'query'][
'pages'] );
80 $this->assertArrayHasKey(
'missing', $data[0][
'query'][
'pages'][-2] );
81 $this->assertArrayHasKey(
'invalid', $data[0][
'query'][
'pages'][-1] );
95 'wgCapitalLinks' =>
true,
99 $exceptionCaught =
false;
101 $this->assertEquals( $expected, $api->titlePartToKey( $titlePart, $namespace ) );
103 $exceptionCaught =
true;
105 $this->assertEquals( $expectException, $exceptionCaught,
106 'ApiUsageException thrown by titlePartToKey' );
127 new FauxRequest( [
'action' =>
'query',
'meta' =>
'siteinfo' ] )
129 $queryApi =
new ApiQuery( $api,
'query' );
130 $modules = $queryApi->getModuleManager()->getNamesWithClasses();
132 foreach (
$modules as $name => $class ) {
134 class_exists( $class ),
135 'Class ' . $class .
' for api module ' . $name .
' does not exist (with exact case)'
$wgMetaNamespace
Name of the project namespace.
This is the main API class, used for both external and internal processing.
API Database medium ApiQuery.
testTitlesAreRejectedIfInvalid()
testClassNamesInModuleManager()
Test if all classes in the query module manager exists.
testTitlesGetNormalized()
provideTestTitlePartToKey()
testTitlePartToKey( $titlePart, $namespace, $expected, $expectException)
Test the ApiBase::titlePartToKey function.
This is the main query class.
doLogin( $testUser='sysop')
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
Exception used to abort API execution with an error.
WebRequest clone which takes values from a provided array.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e