Merge "Deprecate ORMTable::getFieldPrefix"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiMainTest.php
index 8c5f540..4bf6deb 100644 (file)
 class ApiMainTest extends ApiTestCase {
 
        /**
-        * Test that the API will accept a FauxRequest and execute. The help action
-        * (default) throws a UsageException. Just validate we're getting proper XML
-        *
-        * @expectedException UsageException
+        * Test that the API will accept a FauxRequest and execute.
         */
        public function testApi() {
                $api = new ApiMain(
-                       new FauxRequest( array( 'action' => 'help', 'format' => 'xml' ) )
+                       new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) )
                );
                $api->execute();
-               $api->getPrinter()->setBufferResult( true );
-               $api->printResult( false );
-               $resp = $api->getPrinter()->getBuffer();
-
-               libxml_use_internal_errors( true );
-               $sxe = simplexml_load_string( $resp );
-               $this->assertNotInternalType( "bool", $sxe );
-               $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
+               $data = $api->getResultData();
+               $this->assertInternalType( 'array', $data );
+               $this->assertArrayHasKey( 'query', $data );
        }
 
        public static function provideAssert() {
@@ -55,7 +47,7 @@ class ApiMainTest extends ApiTestCase {
         * @dataProvider provideAssert
         * @param User $user
         * @param string $assert
-        * @param string|bool $error false if no error expected
+        * @param string|bool $error False if no error expected
         */
        public function testAssert( $user, $assert, $error ) {
                try {