} );
$reset[] = new \ScopedCallback( 'restore_error_handler' );
- $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+ $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
if ( $rProp->getValue() ) {
$old = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
$oldStore = $old->store;
$oldLogger = $old->logger;
$reset[] = new \ScopedCallback(
- [ 'MediaWiki\\Session\\PHPSessionHandler', 'install' ],
+ [ PHPSessionHandler::class, 'install' ],
[ $oldManager, $oldStore, $oldLogger ]
);
}
public function testEnableFlags() {
$handler = \TestingAccessWrapper::newFromObject(
- $this->getMockBuilder( 'MediaWiki\\Session\\PHPSessionHandler' )
+ $this->getMockBuilder( PHPSessionHandler::class )
->setMethods( null )
->disableOriginalConstructor()
->getMock()
);
- $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+ $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
$reset = new \ScopedCallback( [ $rProp, 'setValue' ], [ $rProp->getValue() ] );
$rProp->setValue( $handler );
// Test that write doesn't break if the session is invalid
$session = $manager->getEmptySession();
$session->persist();
- session_id( $session->getId() );
+ $id = $session->getId();
+ unset( $session );
+ session_id( $id );
session_start();
$this->mergeMwGlobalArrayValue( 'wgHooks', [
'SessionCheckInfo' => [ function ( &$reason ) {
return false;
} ],
] );
- $this->assertNull( $manager->getSessionById( $session->getId(), true ), 'sanity check' );
+ $this->assertNull( $manager->getSessionById( $id, true ), 'sanity check' );
session_write_close();
+
$this->mergeMwGlobalArrayValue( 'wgHooks', [
'SessionCheckInfo' => [],
] );
- $this->assertNotNull( $manager->getSessionById( $session->getId(), true ), 'sanity check' );
+ $this->assertNotNull( $manager->getSessionById( $id, true ), 'sanity check' );
}
public static function provideHandlers() {
* @expectedExceptionMessage Attempt to use PHP session management
*/
public function testDisabled( $method, $args ) {
- $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+ $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
$rProp->setAccessible( true );
- $handler = $this->getMockBuilder( 'MediaWiki\\Session\\PHPSessionHandler' )
+ $handler = $this->getMockBuilder( PHPSessionHandler::class )
->setMethods( null )
->disableOriginalConstructor()
->getMock();
* @expectedExceptionMessageRegExp /: Wrong instance called!$/
*/
public function testWrongInstance( $method, $args ) {
- $handler = $this->getMockBuilder( 'MediaWiki\\Session\\PHPSessionHandler' )
+ $handler = $this->getMockBuilder( PHPSessionHandler::class )
->setMethods( null )
->disableOriginalConstructor()
->getMock();