namespace MediaWiki\Session;
+use Config;
use MediaWikiTestCase;
use User;
+use Wikimedia\TestingAccessWrapper;
/**
* @group Session
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;
* 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 ) {
$id = new SessionId( $info->getId() );
$backend = new SessionBackend( $id, $info, $this->store, $logger, 10 );
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->persist = false;
$priv->requests = [ 100 => new \FauxRequest() ];
$priv->requests[100]->setSessionId( $id );
$priv->usePhpSessionHandling = false;
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$manager->allSessionBackends = [ $backend->getId() => $backend ] + $manager->allSessionBackends;
$manager->allSessionIds = [ $backend->getId() => $id ] + $manager->allSessionIds;
$manager->sessionProviders = [ (string)$this->provider => $this->provider ];
$this->assertSame( self::SESSIONID, $backend->getId() );
$this->assertSame( $id, $backend->getSessionId() );
$this->assertSame( $this->provider, $backend->getProvider() );
- $this->assertInstanceOf( 'User', $backend->getUser() );
+ $this->assertInstanceOf( User::class, $backend->getUser() );
$this->assertSame( 'UTSysop', $backend->getUser()->getName() );
$this->assertSame( $info->wasPersisted(), $backend->isPersistent() );
$this->assertSame( $info->wasRemembered(), $backend->shouldRememberUser() );
$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,
$this->assertSame( self::SESSIONID, $backend->getId() );
$this->assertSame( $id, $backend->getSessionId() );
$this->assertSame( $this->provider, $backend->getProvider() );
- $this->assertInstanceOf( 'User', $backend->getUser() );
+ $this->assertInstanceOf( User::class, $backend->getUser() );
$this->assertTrue( $backend->getUser()->isAnon() );
$this->assertSame( $info->wasPersisted(), $backend->isPersistent() );
$this->assertSame( $info->wasRemembered(), $backend->shouldRememberUser() );
$this->assertSame( $info->forceHTTPS(), $backend->shouldForceHTTPS() );
- $this->assertSame( $expire, \TestingAccessWrapper::newFromObject( $backend )->expires );
+ $this->assertSame( $expire, TestingAccessWrapper::newFromObject( $backend )->expires );
$this->assertSame( [ 'foo' ], $backend->getProviderMetadata() );
}
public function testSessionStuff() {
$backend = $this->getBackend();
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->requests = []; // Remove dummy session
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$request1 = new \FauxRequest();
$session1 = $backend->getSession( $request1 );
$this->assertInstanceOf( Session::class, $session2 );
$this->assertSame( 2, count( $priv->requests ) );
- $index = \TestingAccessWrapper::newFromObject( $session1 )->index;
+ $index = TestingAccessWrapper::newFromObject( $session1 )->index;
$this->assertSame( $request1, $backend->getRequest( $index ) );
$this->assertSame( null, $backend->suggestLoginUsername( $index ) );
public function testSetProviderMetadata() {
$backend = $this->getBackend();
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->providerMetadata = [ 'dummy' ];
try {
public function testResetId() {
$id = session_id();
- $builder = $this->getMockBuilder( 'DummySessionProvider' )
+ $builder = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistsSessionId', 'sessionIdWasReset' ] );
$this->provider = $builder->getMock();
->will( $this->returnValue( false ) );
$this->provider->expects( $this->never() )->method( 'sessionIdWasReset' );
$backend = $this->getBackend( User::newFromName( 'UTSysop' ) );
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$sessionId = $backend->getSessionId();
$backend->resetId();
$this->assertSame( self::SESSIONID, $backend->getId() );
$backend = $this->getBackend();
$this->provider->expects( $this->once() )->method( 'sessionIdWasReset' )
->with( $this->identicalTo( $backend ), $this->identicalTo( self::SESSIONID ) );
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$sessionId = $backend->getSessionId();
$backend->resetId();
$this->assertNotEquals( self::SESSIONID, $backend->getId() );
}
public function testPersist() {
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistSession' ] )->getMock();
$this->provider->expects( $this->once() )->method( 'persistSession' );
$backend = $this->getBackend();
$this->provider = null;
$backend = $this->getBackend();
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$wrap->persist = true;
$wrap->expires = 0;
$backend->persist();
}
public function testUnpersist() {
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'unpersistSession' ] )->getMock();
$this->provider->expects( $this->once() )->method( 'unpersistSession' );
$backend = $this->getBackend();
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$wrap->store = new \CachedBagOStuff( $this->store );
$wrap->persist = true;
$wrap->dataDirty = true;
$backend->unpersist();
$this->assertFalse( $backend->isPersistent() );
$this->assertFalse( $this->store->getSession( self::SESSIONID ) );
- $this->assertNotFalse( $wrap->store->get( wfMemcKey( 'MWSession', self::SESSIONID ) ) );
+ $this->assertNotFalse(
+ $wrap->store->get( $wrap->store->makeKey( 'MWSession', self::SESSIONID ) )
+ );
}
public function testRememberUser() {
public function testSetUser() {
$user = static::getTestSysop()->getUser();
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'canChangeUser' ] )->getMock();
$this->provider->expects( $this->any() )->method( 'canChangeUser' )
->will( $this->returnValue( false ) );
public function testDirty() {
$backend = $this->getBackend();
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->dataDirty = false;
$backend->dirty();
$this->assertTrue( $priv->dataDirty );
$backend = $this->getBackend();
$data = $backend->getData();
$this->assertSame( [], $data );
- $this->assertTrue( \TestingAccessWrapper::newFromObject( $backend )->dataDirty );
+ $this->assertTrue( TestingAccessWrapper::newFromObject( $backend )->dataDirty );
$data['???'] = '!!!';
$this->assertSame( [ '???' => '!!!' ], $data );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend();
$this->assertSame( $testData, $backend->getData() );
- $this->assertFalse( \TestingAccessWrapper::newFromObject( $backend )->dataDirty );
+ $this->assertFalse( TestingAccessWrapper::newFromObject( $backend )->dataDirty );
}
public function testAddData() {
$backend = $this->getBackend();
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->data = [ 'foo' => 1 ];
$priv->dataDirty = false;
public function testDelaySave() {
$this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SessionMetadata' => [ $this ] ] );
$backend = $this->getBackend();
- $priv = \TestingAccessWrapper::newFromObject( $backend );
+ $priv = TestingAccessWrapper::newFromObject( $backend );
$priv->persist = true;
// Saves happen normally when no delay is in effect
->setMethods( [ 'onSessionMetadata' ] )->getMock();
$neverHook->expects( $this->never() )->method( 'onSessionMetadata' );
- $builder = $this->getMockBuilder( 'DummySessionProvider' )
+ $builder = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistSession', 'unpersistSession' ] );
$neverProvider = $builder->getMock();
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = false;
- \TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = false;
+ TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
$this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SessionMetadata' => [ $neverHook ] ] );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
- \TestingAccessWrapper::newFromObject( $backend )->requests[100]
+ TestingAccessWrapper::newFromObject( $backend )->requests[100]
->setSessionId( new SessionId( 'x' ) );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = false;
- \TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = false;
+ TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
$backend->save();
$this->assertTrue( $this->onSessionMetadataCalled );
$blob = $this->store->getSession( self::SESSIONID );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
- \TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
$backend->save();
$this->assertTrue( $this->onSessionMetadataCalled );
$blob = $this->store->getSession( self::SESSIONID );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
- \TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->forcePersist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
$backend->save();
$this->assertTrue( $this->onSessionMetadataCalled );
$blob = $this->store->getSession( self::SESSIONID );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = true;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
$backend->save();
$this->assertTrue( $this->onSessionMetadataCalled );
$blob = $this->store->getSession( self::SESSIONID );
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
- \TestingAccessWrapper::newFromObject( $backend )->dataHash = 'Doesn\'t match';
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = false;
+ TestingAccessWrapper::newFromObject( $backend )->dataHash = 'Doesn\'t match';
$backend->save();
$this->assertTrue( $this->onSessionMetadataCalled );
$blob = $this->store->getSession( self::SESSIONID );
}
// SessionManager::preventSessionsForUser
- \TestingAccessWrapper::newFromObject( $this->manager )->preventUsers = [
+ TestingAccessWrapper::newFromObject( $this->manager )->preventUsers = [
$user->getName() => true,
];
$this->provider = $neverProvider;
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- \TestingAccessWrapper::newFromObject( $backend )->persist = true;
+ TestingAccessWrapper::newFromObject( $backend )->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
- \TestingAccessWrapper::newFromObject( $backend )->metaDirty = true;
- \TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->metaDirty = true;
+ TestingAccessWrapper::newFromObject( $backend )->dataDirty = true;
$backend->save();
$this->assertFalse( $this->store->getSession( self::SESSIONID ), 'making sure it didn\'t save' );
}
$testData = [ 'foo' => 'foo!', 'bar', [ 'baz', null ] ];
// Not persistent
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistSession' ] )->getMock();
$this->provider->expects( $this->never() )->method( 'persistSession' );
$this->onSessionMetadataCalled = false;
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
$wrap->metaDirty = false;
$wrap->dataDirty = false;
$this->assertNotEquals( 0, $wrap->expires );
// Persistent
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistSession' ] )->getMock();
$this->provider->expects( $this->atLeastOnce() )->method( 'persistSession' );
$this->onSessionMetadataCalled = false;
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$wrap->persist = true;
$this->assertTrue( $backend->isPersistent(), 'sanity check' );
$wrap->metaDirty = false;
$this->assertNotEquals( 0, $wrap->expires );
// Not persistent, not expiring
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'persistSession' ] )->getMock();
$this->provider->expects( $this->never() )->method( 'persistSession' );
$this->onSessionMetadataCalled = false;
$this->store->setSessionData( self::SESSIONID, $testData );
$backend = $this->getBackend( $user );
$this->store->deleteSession( self::SESSIONID );
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$this->assertFalse( $backend->isPersistent(), 'sanity check' );
$wrap->metaDirty = false;
$wrap->dataDirty = false;
if ( !PHPSessionHandler::isEnabled() ) {
$rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
- $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
+ $handler = TestingAccessWrapper::newFromObject( $rProp->getValue() );
$resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
session_write_close();
$handler->enable = false;
}
$backend = $this->getBackend( static::getTestSysop()->getUser() );
- \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = true;
+ TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = true;
$resetSingleton = TestUtils::setSessionManagerSingleton( $this->manager );
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$request = \RequestContext::getMain()->getRequest();
$manager->globalSession = $backend->getSession( $request );
$manager->globalSessionRequest = $request;
session_id( '' );
- \TestingAccessWrapper::newFromObject( $backend )->checkPHPSession();
+ TestingAccessWrapper::newFromObject( $backend )->checkPHPSession();
$this->assertSame( $backend->getId(), session_id() );
session_write_close();
$backend2 = $this->getBackend(
User::newFromName( 'UTSysop' ), 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
);
- \TestingAccessWrapper::newFromObject( $backend2 )->usePhpSessionHandling = true;
+ TestingAccessWrapper::newFromObject( $backend2 )->usePhpSessionHandling = true;
session_id( '' );
- \TestingAccessWrapper::newFromObject( $backend2 )->checkPHPSession();
+ TestingAccessWrapper::newFromObject( $backend2 )->checkPHPSession();
$this->assertSame( '', session_id() );
}
if ( !PHPSessionHandler::isEnabled() ) {
$rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
- $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
+ $handler = TestingAccessWrapper::newFromObject( $rProp->getValue() );
$resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
session_write_close();
$handler->enable = false;
}
$backend = $this->getBackend( User::newFromName( 'UTSysop' ) );
- \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = true;
+ TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = true;
$resetSingleton = TestUtils::setSessionManagerSingleton( $this->manager );
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$request = \RequestContext::getMain()->getRequest();
$manager->globalSession = $backend->getSession( $request );
$manager->globalSessionRequest = $request;
if ( !PHPSessionHandler::isEnabled() ) {
$rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
- $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
+ $handler = TestingAccessWrapper::newFromObject( $rProp->getValue() );
$resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
session_write_close();
$handler->enable = false;
}
$backend = $this->getBackend( User::newFromName( 'UTSysop' ) );
- $wrap = \TestingAccessWrapper::newFromObject( $backend );
+ $wrap = TestingAccessWrapper::newFromObject( $backend );
$wrap->usePhpSessionHandling = true;
$wrap->persist = true;
$resetSingleton = TestUtils::setSessionManagerSingleton( $this->manager );
- $manager = \TestingAccessWrapper::newFromObject( $this->manager );
+ $manager = TestingAccessWrapper::newFromObject( $this->manager );
$request = \RequestContext::getMain()->getRequest();
$manager->globalSession = $backend->getSession( $request );
$manager->globalSessionRequest = $request;
}
public function testGetAllowedUserRights() {
- $this->provider = $this->getMockBuilder( 'DummySessionProvider' )
+ $this->provider = $this->getMockBuilder( \DummySessionProvider::class )
->setMethods( [ 'getAllowedUserRights' ] )
->getMock();
$this->provider->expects( $this->any() )->method( 'getAllowedUserRights' )