10 class ApiMainTest
extends ApiTestCase
{
13 * Test that the API will accept a FauxRequest and execute.
15 public function testApi() {
17 new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) )
20 $data = $api->getResultData();
21 $this->assertInternalType( 'array', $data );
22 $this->assertArrayHasKey( 'query', $data );
25 public static function provideAssert() {
28 $bot->setName( 'Bot' );
29 $bot->addToDatabase();
30 $bot->addGroup( 'bot' );
32 $user->setName( 'User' );
33 $user->addToDatabase();
35 array( $anon, 'user', 'assertuserfailed' ),
36 array( $user, 'user', false ),
37 array( $user, 'bot', 'assertbotfailed' ),
38 array( $bot, 'user', false ),
39 array( $bot, 'bot', false ),
44 * Tests the assert={user|bot} functionality
46 * @covers ApiMain::checkAsserts
47 * @dataProvider provideAssert
49 * @param string $assert
50 * @param string|bool $error False if no error expected
52 public function testAssert( $user, $assert, $error ) {
54 $this->doApiRequest( array(
57 ), null, null, $user );
58 $this->assertFalse( $error ); // That no error was expected
59 } catch ( UsageException
$e ) {
60 $this->assertEquals( $e->getCodeString(), $error );