Remove unused method parameters from TestBagOStuff
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Wed, 10 Jan 2018 13:32:56 +0000 (14:32 +0100)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 30 Jan 2018 16:04:45 +0000 (11:04 -0500)
This is a test mock exclusively used in tests. All code I'm removing here
is unused and neither needed nor covered by any test.

Change-Id: Ifd010c49973460f6fbb2cd83f8fd63488f5fd291

tests/phpunit/includes/session/SessionBackendTest.php
tests/phpunit/includes/session/SessionManagerTest.php
tests/phpunit/includes/session/TestBagOStuff.php

index 88f58cf..e460960 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace MediaWiki\Session;
 
+use Config;
 use MediaWikiTestCase;
 use User;
 use Wikimedia\TestingAccessWrapper;
@@ -14,9 +15,16 @@ use Wikimedia\TestingAccessWrapper;
 class SessionBackendTest extends MediaWikiTestCase {
        const SESSIONID = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
 
+       /** @var SessionManager */
        protected $manager;
+
+       /** @var Config */
        protected $config;
+
+       /** @var SessionProvider */
        protected $provider;
+
+       /** @var TestBagOStuff */
        protected $store;
 
        protected $onSessionMetadataCalled = false;
@@ -25,6 +33,7 @@ class SessionBackendTest extends MediaWikiTestCase {
         * Returns a non-persistent backend that thinks it has at least one session active
         * @param User|null $user
         * @param string $id
+        * @return SessionBackend
         */
        protected function getBackend( User $user = null, $id = null ) {
                if ( !$this->config ) {
@@ -149,7 +158,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                $this->assertSame( $info->forceHTTPS(), $backend->shouldForceHTTPS() );
 
                $expire = time() + 100;
-               $this->store->setSessionMeta( self::SESSIONID, [ 'expires' => $expire ], 2 );
+               $this->store->setSessionMeta( self::SESSIONID, [ 'expires' => $expire ] );
 
                $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [
                        'provider' => $this->provider,
index 6c989f3..e042f76 100644 (file)
@@ -14,7 +14,14 @@ use Wikimedia\TestingAccessWrapper;
  */
 class SessionManagerTest extends MediaWikiTestCase {
 
-       protected $config, $logger, $store;
+       /** @var \HashConfig */
+       private $config;
+
+       /** @var \TestLogger */
+       private $logger;
+
+       /** @var TestBagOStuff */
+       private $store;
 
        protected function getManager() {
                \ObjectCache::$instances['testSessionStore'] = new TestBagOStuff();
index bac2088..f9e30f0 100644 (file)
@@ -14,53 +14,44 @@ class TestBagOStuff extends \CachedBagOStuff {
        /**
         * @param string $id Session ID
         * @param array $data Session data
-        * @param int $expiry
-        * @param User $user User for metadata
         */
-       public function setSessionData( $id, array $data, $expiry = 0, User $user = null ) {
-               $this->setSession( $id, [ 'data' => $data ], $expiry, $user );
+       public function setSessionData( $id, array $data ) {
+               $this->setSession( $id, [ 'data' => $data ] );
        }
 
        /**
         * @param string $id Session ID
         * @param array $metadata Session metadata
-        * @param int $expiry
         */
-       public function setSessionMeta( $id, array $metadata, $expiry = 0 ) {
-               $this->setSession( $id, [ 'metadata' => $metadata ], $expiry );
+       public function setSessionMeta( $id, array $metadata ) {
+               $this->setSession( $id, [ 'metadata' => $metadata ] );
        }
 
        /**
         * @param string $id Session ID
         * @param array $blob Session metadata and data
-        * @param int $expiry
-        * @param User $user User for metadata
         */
-       public function setSession( $id, array $blob, $expiry = 0, User $user = null ) {
+       public function setSession( $id, array $blob ) {
                $blob += [
                        'data' => [],
                        'metadata' => [],
                ];
                $blob['metadata'] += [
-                       'userId' => $user ? $user->getId() : 0,
-                       'userName' => $user ? $user->getName() : null,
-                       'userToken' => $user ? $user->getToken( true ) : null,
+                       'userId' => 0,
+                       'userName' => null,
+                       'userToken' => null,
                        'provider' => 'DummySessionProvider',
                ];
 
-               $this->setRawSession( $id, $blob, $expiry, $user );
+               $this->setRawSession( $id, $blob );
        }
 
        /**
         * @param string $id Session ID
         * @param array|mixed $blob Session metadata and data
-        * @param int $expiry
         */
-       public function setRawSession( $id, $blob, $expiry = 0 ) {
-               if ( $expiry <= 0 ) {
-                       $expiry = \RequestContext::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' );
-               }
-
+       public function setRawSession( $id, $blob ) {
+               $expiry = \RequestContext::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' );
                $this->set( $this->makeKey( 'MWSession', $id ), $blob, $expiry );
        }