/**
* Override the singleton for unit testing
* @param SessionManager|null $manager
- * @return \\ScopedCallback|null
+ * @return \\Wikimedia\ScopedCallback|null
*/
public static function setSessionManagerSingleton( SessionManager $manager = null ) {
session_write_close();
$rInstance = new \ReflectionProperty(
- 'MediaWiki\\Session\\SessionManager', 'instance'
+ SessionManager::class, 'instance'
);
$rInstance->setAccessible( true );
$rGlobalSession = new \ReflectionProperty(
- 'MediaWiki\\Session\\SessionManager', 'globalSession'
+ SessionManager::class, 'globalSession'
);
$rGlobalSession->setAccessible( true );
$rGlobalSessionRequest = new \ReflectionProperty(
- 'MediaWiki\\Session\\SessionManager', 'globalSessionRequest'
+ SessionManager::class, 'globalSessionRequest'
);
$rGlobalSessionRequest->setAccessible( true );
$oldInstance = $rInstance->getValue();
- $reset = array(
- array( $rInstance, $oldInstance ),
- array( $rGlobalSession, $rGlobalSession->getValue() ),
- array( $rGlobalSessionRequest, $rGlobalSessionRequest->getValue() ),
- );
+ $reset = [
+ [ $rInstance, $oldInstance ],
+ [ $rGlobalSession, $rGlobalSession->getValue() ],
+ [ $rGlobalSessionRequest, $rGlobalSessionRequest->getValue() ],
+ ];
$rInstance->setValue( $manager );
$rGlobalSession->setValue( null );
PHPSessionHandler::install( $manager );
}
- return new \ScopedCallback( function () use ( &$reset, $oldInstance ) {
+ return new \Wikimedia\ScopedCallback( function () use ( &$reset, $oldInstance ) {
foreach ( $reset as &$arr ) {
$arr[0]->setValue( $arr[1] );
}
* fields necessary.
*/
public static function getDummySessionBackend() {
- $rc = new \ReflectionClass( 'MediaWiki\\Session\\SessionBackend' );
+ $rc = new \ReflectionClass( SessionBackend::class );
if ( !method_exists( $rc, 'newInstanceWithoutConstructor' ) ) {
\PHPUnit_Framework_Assert::markTestSkipped(
'ReflectionClass::newInstanceWithoutConstructor isn\'t available'
* @return Session
*/
public static function getDummySession( $backend = null, $index = -1, $logger = null ) {
- $rc = new \ReflectionClass( 'MediaWiki\\Session\\Session' );
+ $rc = new \ReflectionClass( Session::class );
if ( !method_exists( $rc, 'newInstanceWithoutConstructor' ) ) {
\PHPUnit_Framework_Assert::markTestSkipped(
'ReflectionClass::newInstanceWithoutConstructor isn\'t available'