}
return false;
} );
- $reset[] = new \ScopedCallback( 'restore_error_handler' );
+ $reset[] = new \Wikimedia\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() );
$oldManager = $old->manager;
$oldStore = $old->store;
$oldLogger = $old->logger;
- $reset[] = new \ScopedCallback(
- [ 'MediaWiki\\Session\\PHPSessionHandler', 'install' ],
+ $reset[] = new \Wikimedia\ScopedCallback(
+ [ 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() ] );
+ $reset = new \Wikimedia\ScopedCallback( [ $rProp, 'setValue' ], [ $rProp->getValue() ] );
$rProp->setValue( $handler );
$handler->setEnableFlags( 'enable' );
] );
PHPSessionHandler::install( $manager );
$wrap = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
- $reset[] = new \ScopedCallback(
+ $reset[] = new \Wikimedia\ScopedCallback(
[ $wrap, 'setEnableFlags' ],
[ $wrap->enable ? $wrap->warn ? 'warn' : 'enable' : 'disable' ]
);
$this->assertSame( $expect, $_SESSION );
}
- // Test expiry
- session_write_close();
- ini_set( 'session.gc_divisor', 1 );
- ini_set( 'session.gc_probability', 1 );
- sleep( 3 );
- session_start();
- $this->assertSame( [], $_SESSION );
-
// Re-fill the session, then test that session_destroy() works.
$_SESSION['AuthenticationSessionTest'] = $rand;
session_write_close();
* @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();
\TestingAccessWrapper::newFromObject( $handler )->setEnableFlags( 'disable' );
$oldValue = $rProp->getValue();
$rProp->setValue( $handler );
- $reset = new \ScopedCallback( [ $rProp, 'setValue' ], [ $oldValue ] );
+ $reset = new \Wikimedia\ScopedCallback( [ $rProp, 'setValue' ], [ $oldValue ] );
call_user_func_array( [ $handler, $method ], $args );
}
* @expectedExceptionMessageRegExp /: Wrong instance called!$/
*/
public function testWrongInstance( $method, $args ) {
- $handler = $this->getMockBuilder( 'MediaWiki\\Session\\PHPSessionHandler' )
+ $handler = $this->getMockBuilder( PHPSessionHandler::class )
->setMethods( null )
->disableOriginalConstructor()
->getMock();