15 'InterwikiLoadPrefix' => [
16 function ( $prefix, &$data ) {
17 if ( $prefix ==
'apiquerytestiw' ) {
18 $data = [
'iw_url' =>
'wikipedia' ];
30 'wgCapitalLinks' =>
true,
35 'titles' =>
'Project:articleA|article_B' ] );
37 $this->assertArrayHasKey(
'query', $data[0] );
38 $this->assertArrayHasKey(
'normalized', $data[0][
'query'] );
45 'fromencoded' =>
false,
46 'from' =>
'Project:articleA',
47 'to' => $to->getPrefixedText(),
49 $data[0][
'query'][
'normalized'][0]
54 'fromencoded' =>
false,
55 'from' =>
'article_B',
58 $data[0][
'query'][
'normalized'][1]
64 while ( !$title || Title::newFromText( $title )->exists() ) {
65 $title = md5( mt_rand( 0, 100000 ) );
70 'titles' => $title .
'|Talk:' ] );
72 $this->assertArrayHasKey(
'query', $data[0] );
73 $this->assertArrayHasKey(
'pages', $data[0][
'query'] );
74 $this->assertEquals( 2, count( $data[0][
'query'][
'pages'] ) );
76 $this->assertArrayHasKey( -2, $data[0][
'query'][
'pages'] );
77 $this->assertArrayHasKey( -1, $data[0][
'query'][
'pages'] );
79 $this->assertArrayHasKey(
'missing', $data[0][
'query'][
'pages'][-2] );
80 $this->assertArrayHasKey(
'invalid', $data[0][
'query'][
'pages'][-1] );
89 $this->assertArrayHasKey(
'query', $data[0] );
90 $this->assertArrayHasKey(
'pages', $data[0][
'query'] );
91 $this->assertEquals( 1, count( $data[0][
'query'][
'pages'] ) );
92 $this->assertArrayHasKey( -1, $data[0][
'query'][
'pages'] );
93 $this->assertArrayHasKey(
'invalid', $data[0][
'query'][
'pages'][-1] );
107 'wgCapitalLinks' =>
true,
111 $exceptionCaught =
false;
113 $this->assertEquals( $expected, $api->titlePartToKey( $titlePart, $namespace ) );
115 $exceptionCaught =
true;
117 $this->assertEquals( $expectException, $exceptionCaught,
118 'ApiUsageException thrown by titlePartToKey' );
139 new FauxRequest( [
'action' =>
'query',
'meta' =>
'siteinfo' ] )
141 $queryApi =
new ApiQuery( $api,
'query' );
142 $modules = $queryApi->getModuleManager()->getNamesWithClasses();
144 foreach (
$modules as $name => $class ) {
146 class_exists( $class ),
147 '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()
testTitlesWithWhitespaces()
provideTestTitlePartToKey()
testTitlePartToKey( $titlePart, $namespace, $expected, $expectException)
Test the ApiBase::titlePartToKey function.
This is the main query class.
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=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