Merge "exception: Add newline at the end of a debugging line for CLI users"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiMainTest.php
index eff41e3..3e6ceb7 100644 (file)
@@ -1,7 +1,10 @@
 <?php
 
+use Wikimedia\TestingAccessWrapper;
+
 /**
  * @group API
+ * @group Database
  * @group medium
  *
  * @covers ApiMain
@@ -330,8 +333,6 @@ class ApiMainTest extends ApiTestCase {
        }
 
        public static function provideApiErrorFormatterCreation() {
-               global $wgContLang;
-
                return [
                        'Default (BC)' => [ [], [
                                'uselang' => 'ru',
@@ -381,9 +382,9 @@ class ApiMainTest extends ApiTestCase {
                        'uselang=content' => [
                                [ 'uselang' => 'content', 'errorformat' => 'plaintext' ],
                                [
-                                       'uselang' => $wgContLang->getCode(),
+                                       'uselang' => 'en',
                                        'class' => ApiErrorFormatter::class,
-                                       'lang' => $wgContLang->getCode(),
+                                       'lang' => 'en',
                                        'format' => 'plaintext',
                                        'usedb' => false,
                                ]
@@ -393,7 +394,7 @@ class ApiMainTest extends ApiTestCase {
                                [
                                        'uselang' => 'ru',
                                        'class' => ApiErrorFormatter::class,
-                                       'lang' => $wgContLang->getCode(),
+                                       'lang' => 'en',
                                        'format' => 'plaintext',
                                        'usedb' => false,
                                ]
@@ -451,7 +452,10 @@ class ApiMainTest extends ApiTestCase {
                $context->setRequest( new FauxRequest( [ 'errorformat' => 'plaintext' ] ) );
                $context->setLanguage( 'en' );
                $context->setConfig( new MultiConfig( [
-                       new HashConfig( [ 'ShowHostnames' => true, 'ShowSQLErrors' => false ] ),
+                       new HashConfig( [
+                               'ShowHostnames' => true, 'ShowSQLErrors' => false,
+                               'ShowExceptionDetails' => true, 'ShowDBErrorBacktrace' => true,
+                       ] ),
                        $context->getConfig()
                ] ) );
 
@@ -470,7 +474,7 @@ class ApiMainTest extends ApiTestCase {
                );
        }
 
-       // Not static so $this->getMock() can be used
+       // Not static so $this can be used
        public function provideExceptionErrors() {
                $reqId = WebRequest::getRequestId();
                $doclink = wfExpandUrl( wfScript( 'api' ) );
@@ -483,7 +487,9 @@ class ApiMainTest extends ApiTestCase {
                        MWExceptionHandler::getRedactedTraceAsString( $ex )
                )->inLanguage( 'en' )->useDatabase( false )->text();
 
-               $dbex = new DBQueryError( $this->getMock( 'IDatabase' ), 'error', 1234, 'SELECT 1', __METHOD__ );
+               $dbex = new DBQueryError(
+                       $this->createMock( 'IDatabase' ),
+                       'error', 1234, 'SELECT 1', __METHOD__ );
                $dbtrace = wfMessage( 'api-exception-trace',
                        get_class( $dbex ),
                        $dbex->getFile(),