9 class ApiMainTest
extends ApiTestCase
{
12 * Test that the API will accept a FauxRequest and execute.
14 public function testApi() {
16 new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) )
19 $data = $api->getResult()->getResultData();
20 $this->assertInternalType( 'array', $data );
21 $this->assertArrayHasKey( 'query', $data );
24 public static function provideAssert() {
26 array( false, array(), 'user', 'assertuserfailed' ),
27 array( true, array(), 'user', false ),
28 array( true, array(), 'bot', 'assertbotfailed' ),
29 array( true, array( 'bot' ), 'user', false ),
30 array( true, array( 'bot' ), 'bot', false ),
35 * Tests the assert={user|bot} functionality
37 * @covers ApiMain::checkAsserts
38 * @dataProvider provideAssert
39 * @param bool $registered
40 * @param array $rights
41 * @param string $assert
42 * @param string|bool $error False if no error expected
44 public function testAssert( $registered, $rights, $assert, $error ) {
49 $user->mRights
= $rights;
51 $this->doApiRequest( array(
54 ), null, null, $user );
55 $this->assertFalse( $error ); // That no error was expected
56 } catch ( UsageException
$e ) {
57 $this->assertEquals( $e->getCodeString(), $error );
62 * Test if all classes in the main module manager exists
64 public function testClassNamesInModuleManager() {
65 global $wgAutoloadLocalClasses, $wgAutoloadClasses;
67 // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php
68 $classes = $wgAutoloadLocalClasses +
$wgAutoloadClasses;
71 new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) )
73 $modules = $api->getModuleManager()->getNamesWithClasses();
74 foreach ( $modules as $name => $class ) {
75 $this->assertArrayHasKey(
78 'Class ' . $class . ' for api module ' . $name . ' not in autoloader (with exact case)'