Merge "Update tests to Selenium 3"
[lhc/web/wiklou.git] / tests / phpunit / includes / session / TestBagOStuff.php
index e674e7b..759eca6 100644 (file)
@@ -5,7 +5,11 @@ namespace MediaWiki\Session;
 /**
  * BagOStuff with utility functions for MediaWiki\\Session\\* testing
  */
-class TestBagOStuff extends \HashBagOStuff {
+class TestBagOStuff extends \CachedBagOStuff {
+
+       public function __construct() {
+               parent::__construct( new \HashBagOStuff );
+       }
 
        /**
         * @param string $id Session ID
@@ -14,7 +18,7 @@ class TestBagOStuff extends \HashBagOStuff {
         * @param User $user User for metadata
         */
        public function setSessionData( $id, array $data, $expiry = 0, User $user = null ) {
-               $this->setSession( $id, array( 'data' => $data ), $expiry, $user );
+               $this->setSession( $id, [ 'data' => $data ], $expiry, $user );
        }
 
        /**
@@ -23,7 +27,7 @@ class TestBagOStuff extends \HashBagOStuff {
         * @param int $expiry Expiry
         */
        public function setSessionMeta( $id, array $metadata, $expiry = 0 ) {
-               $this->setSession( $id, array( 'metadata' => $metadata ), $expiry );
+               $this->setSession( $id, [ 'metadata' => $metadata ], $expiry );
        }
 
        /**
@@ -33,16 +37,16 @@ class TestBagOStuff extends \HashBagOStuff {
         * @param User $user User for metadata
         */
        public function setSession( $id, array $blob, $expiry = 0, User $user = null ) {
-               $blob += array(
-                       'data' => array(),
-                       'metadata' => array(),
-               );
-               $blob['metadata'] += array(
+               $blob += [
+                       'data' => [],
+                       'metadata' => [],
+               ];
+               $blob['metadata'] += [
                        'userId' => $user ? $user->getId() : 0,
                        'userName' => $user ? $user->getName() : null,
                        'userToken' => $user ? $user->getToken( true ) : null,
                        'provider' => 'DummySessionProvider',
-               );
+               ];
 
                $this->setRawSession( $id, $blob, $expiry, $user );
        }
@@ -68,6 +72,14 @@ class TestBagOStuff extends \HashBagOStuff {
                return $this->get( wfMemcKey( 'MWSession', $id ) );
        }
 
+       /**
+        * @param string $id Session ID
+        * @return mixed
+        */
+       public function getSessionFromBackend( $id ) {
+               return $this->backend->get( wfMemcKey( 'MWSession', $id ) );
+       }
+
        /**
         * @param string $id Session ID
         */