$manager = \TestingAccessWrapper::newFromObject( $this->getManager() );
$this->assertSame( $this->config, $manager->config );
$this->assertSame( $this->logger, $manager->logger );
- $this->assertSame( $this->store, $manager->store );
+ $this->assertSame( $this->store, $manager->permStore );
$manager = \TestingAccessWrapper::newFromObject( new SessionManager() );
$this->assertSame( \RequestContext::getMain()->getConfig(), $manager->config );
$manager = \TestingAccessWrapper::newFromObject( new SessionManager( array(
'config' => $this->config,
) ) );
- $this->assertSame( \ObjectCache::$instances['testSessionStore'], $manager->store );
+ $this->assertSame( \ObjectCache::$instances['testSessionStore'], $manager->permStore );
foreach ( array(
'config' => '$options[\'config\'] must be an instance of Config',
$session = $manager->getSessionForRequest( $request );
$this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session );
$this->assertSame( $idEmpty, $session->getId() );
- $this->assertNull( $manager->getPersistedSessionId( $request ) );
// Both providers return info, picks best one
$request->info1 = new SessionInfo( SessionInfo::MIN_PRIORITY + 1, array(
$session = $manager->getSessionForRequest( $request );
$this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session );
$this->assertSame( $id2, $session->getId() );
- $this->assertSame( $id2, $manager->getPersistedSessionId( $request ) );
$request->info1 = new SessionInfo( SessionInfo::MIN_PRIORITY + 2, array(
'provider' => $provider1,
$session = $manager->getSessionForRequest( $request );
$this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session );
$this->assertSame( $id1, $session->getId() );
- $this->assertSame( $id1, $manager->getPersistedSessionId( $request ) );
// Tied priorities
$request->info1 = new SessionInfo( SessionInfo::MAX_PRIORITY, array(
$this->assertContains( $request->info1, $ex->sessionInfos );
$this->assertContains( $request->info2, $ex->sessionInfos );
}
- try {
- $manager->getPersistedSessionId( $request );
- $this->fail( 'Expcected exception not thrown' );
- } catch ( \OverFlowException $ex ) {
- $this->assertStringStartsWith(
- 'Multiple sessions for this request tied for top priority: ',
- $ex->getMessage()
- );
- $this->assertCount( 2, $ex->sessionInfos );
- $this->assertContains( $request->info1, $ex->sessionInfos );
- $this->assertContains( $request->info2, $ex->sessionInfos );
- }
// Bad provider
$request->info1 = new SessionInfo( SessionInfo::MAX_PRIORITY, array(
$ex->getMessage()
);
}
- try {
- $manager->getPersistedSessionId( $request );
- $this->fail( 'Expcected exception not thrown' );
- } catch ( \UnexpectedValueException $ex ) {
- $this->assertSame(
- 'Provider1 returned session info for a different provider: ' . $request->info1,
- $ex->getMessage()
- );
- }
// Unusable session info
$this->logger->setCollect( true );
$session = $manager->getSessionForRequest( $request );
$this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session );
$this->assertSame( $id2, $session->getId() );
- $this->assertSame( $id2, $manager->getPersistedSessionId( $request ) );
$this->logger->setCollect( false );
// Unpersisted session ID
$this->assertSame( $id1, $session->getId() );
$session->persist();
$this->assertTrue( $session->isPersistent(), 'sanity check' );
- $this->assertNull( $manager->getPersistedSessionId( $request ) );
}
public function testGetSessionById() {
$manager = $this->getManager();
+ // Disable the in-process cache so our $this->store->setSession() takes effect.
+ \TestingAccessWrapper::newFromObject( $manager )->tempStore = new \EmptyBagOStuff;
+
try {
$manager->getSessionById( 'bad' );
$this->fail( 'Expected exception not thrown' );
$manager->setLogger( $logger );
$request = new \FauxRequest();
+ // Disable the in-process cache so our $this->store->setSession() takes effect.
+ \TestingAccessWrapper::newFromObject( $manager )->tempStore = new \EmptyBagOStuff;
+
// TestingAccessWrapper can't handle methods with reference arguments, sigh.
$rClass = new \ReflectionClass( $manager );
$rMethod = $rClass->getMethod( 'loadSessionInfoFromStore' );
$this->assertTrue( $info->forceHTTPS() );
$this->assertSame( array(), $logger->getBuffer() );
+ // "Persist" flag from session
+ $this->store->setSessionMeta( $id, $metadata );
+ $info = new SessionInfo( SessionInfo::MIN_PRIORITY, array(
+ 'provider' => $provider,
+ 'id' => $id,
+ 'userInfo' => $userInfo
+ ) );
+ $this->assertTrue( $loadSessionInfoFromStore( $info ) );
+ $this->assertFalse( $info->wasPersisted() );
+ $this->assertSame( array(), $logger->getBuffer() );
+
+ $this->store->setSessionMeta( $id, array( 'persisted' => true ) + $metadata );
+ $info = new SessionInfo( SessionInfo::MIN_PRIORITY, array(
+ 'provider' => $provider,
+ 'id' => $id,
+ 'userInfo' => $userInfo
+ ) );
+ $this->assertTrue( $loadSessionInfoFromStore( $info ) );
+ $this->assertTrue( $info->wasPersisted() );
+ $this->assertSame( array(), $logger->getBuffer() );
+
+ $this->store->setSessionMeta( $id, array( 'persisted' => false ) + $metadata );
+ $info = new SessionInfo( SessionInfo::MIN_PRIORITY, array(
+ 'provider' => $provider,
+ 'id' => $id,
+ 'userInfo' => $userInfo,
+ 'persisted' => true
+ ) );
+ $this->assertTrue( $loadSessionInfoFromStore( $info ) );
+ $this->assertTrue( $info->wasPersisted() );
+ $this->assertSame( array(), $logger->getBuffer() );
+
// Provider refreshSessionInfo() returning false
$info = new SessionInfo( SessionInfo::MIN_PRIORITY, array(
'provider' => $provider3,