Move CSRF token handling into MediaWiki\Session\Session
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiTestCase.php
index 21345ac..52c9fec 100644 (file)
@@ -37,7 +37,6 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
                );
 
                $this->setMwGlobals( array(
-                       'wgMemc' => new EmptyBagOStuff(),
                        'wgAuth' => new StubObject( 'wgAuth', 'AuthPlugin' ),
                        'wgRequest' => new FauxRequest( array() ),
                        'wgUser' => self::$users['sysop']->user,
@@ -48,11 +47,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
 
        protected function tearDown() {
                // Avoid leaking session over tests
-               if ( session_id() != '' ) {
-                       global $wgUser;
-                       $wgUser->logout();
-                       session_destroy();
-               }
+               MediaWiki\Session\SessionManager::getGlobalSession()->clear();
 
                parent::tearDown();
        }
@@ -153,12 +148,12 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
                if ( isset( $session['wsToken'] ) && $session['wsToken'] ) {
                        // @todo Why does this directly mess with the session? Fix that.
                        // add edit token to fake session
-                       $session['wsEditToken'] = $session['wsToken'];
+                       $session['wsTokenSecrets']['default'] = $session['wsToken'];
                        // add token to request parameters
                        $timestamp = wfTimestamp();
                        $params['token'] = hash_hmac( 'md5', $timestamp, $session['wsToken'] ) .
                                dechex( $timestamp ) .
-                               User::EDIT_TOKEN_SUFFIX;
+                               MediaWiki\Session\Token::SUFFIX;
 
                        return $this->doApiRequest( $params, $session, false, $user );
                } else {