Merge "(Bug 44192) Do not attempt to send a real e-mail in ApiAccountCreationTest"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiTestCase.php
index d152b1b..552fbfb 100644 (file)
@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 abstract class ApiTestCase extends MediaWikiLangTestCase {
        protected static $apiUrl;
@@ -9,14 +9,10 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
        protected $apiContext;
 
        protected function setUp() {
-               global $wgContLang, $wgAuth, $wgMemc, $wgRequest, $wgUser, $wgServer;
+               global $wgServer;
 
                parent::setUp();
                self::$apiUrl = $wgServer . wfScript( 'api' );
-               $wgMemc = new EmptyBagOStuff();
-               $wgContLang = Language::factory( 'en' );
-               $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
-               $wgRequest = new FauxRequest( array() );
 
                ApiQueryInfo::resetTokenCache(); // tokens are invalid because we cleared the session
 
@@ -35,10 +31,14 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
                        )
                );
 
-               $wgUser = self::$users['sysop']->user;
+               $this->setMwGlobals( array(
+                       'wgMemc' => new EmptyBagOStuff(),
+                       'wgAuth' => new StubObject( 'wgAuth', 'AuthPlugin' ),
+                       'wgRequest' => new FauxRequest( array() ),
+                       'wgUser' => self::$users['sysop']->user,
+               ) );
 
                $this->apiContext = new ApiTestContext();
-
        }
 
        /**
@@ -145,12 +145,15 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
 
                $token = $data[0]['login']['token'];
 
-               $data = $this->doApiRequest( array(
-                       'action' => 'login',
-                       'lgtoken' => $token,
-                       'lgname' => self::$users['sysop']->username,
-                       'lgpassword' => self::$users['sysop']->password
-                       ), $data[2] );
+               $data = $this->doApiRequest(
+                       array(
+                               'action' => 'login',
+                               'lgtoken' => $token,
+                               'lgname' => self::$users['sysop']->username,
+                               'lgpassword' => self::$users['sysop']->password,
+                       ),
+                       $data[2]
+               );
 
                return $data;
        }
@@ -201,10 +204,11 @@ class UserWrapper {
 }
 
 class MockApi extends ApiBase {
-       public function execute() { }
-       public function getVersion() { }
+       public function execute() {}
+
+       public function getVersion() {}
 
-       public function __construct() { }
+       public function __construct() {}
 
        public function getAllowedParams() {
                return array(