From: Thiemo Mättig Date: Wed, 10 Jan 2018 13:32:56 +0000 (+0100) Subject: Remove unused method parameters from TestBagOStuff X-Git-Tag: 1.31.0-rc.0~768^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=1ade7ff45b245c116a74e1fa6c047d5ced766385;p=lhc%2Fweb%2Fwiklou.git Remove unused method parameters from TestBagOStuff 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 --- diff --git a/tests/phpunit/includes/session/SessionBackendTest.php b/tests/phpunit/includes/session/SessionBackendTest.php index 88f58cf06b..e460960c3e 100644 --- a/tests/phpunit/includes/session/SessionBackendTest.php +++ b/tests/phpunit/includes/session/SessionBackendTest.php @@ -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, diff --git a/tests/phpunit/includes/session/SessionManagerTest.php b/tests/phpunit/includes/session/SessionManagerTest.php index 6c989f3cda..e042f7655a 100644 --- a/tests/phpunit/includes/session/SessionManagerTest.php +++ b/tests/phpunit/includes/session/SessionManagerTest.php @@ -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(); diff --git a/tests/phpunit/includes/session/TestBagOStuff.php b/tests/phpunit/includes/session/TestBagOStuff.php index bac2088d9a..f9e30f06ab 100644 --- a/tests/phpunit/includes/session/TestBagOStuff.php +++ b/tests/phpunit/includes/session/TestBagOStuff.php @@ -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 ); }