Merge "Use namespaced ScopedCallback"
[lhc/web/wiklou.git] / tests / phpunit / includes / session / SessionBackendTest.php
index 7459ed2..8a0adba 100644 (file)
@@ -184,8 +184,8 @@ class SessionBackendTest extends MediaWikiTestCase {
                $request2 = new \FauxRequest();
                $session2 = $backend->getSession( $request2 );
 
-               $this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session1 );
-               $this->assertInstanceOf( 'MediaWiki\\Session\\Session', $session2 );
+               $this->assertInstanceOf( Session::class, $session1 );
+               $this->assertInstanceOf( Session::class, $session2 );
                $this->assertSame( 2, count( $priv->requests ) );
 
                $index = \TestingAccessWrapper::newFromObject( $session1 )->index;
@@ -360,7 +360,7 @@ class SessionBackendTest extends MediaWikiTestCase {
        }
 
        public function testSetUser() {
-               $user = User::newFromName( 'UTSysop' );
+               $user = static::getTestSysop()->getUser();
 
                $this->provider = $this->getMock( 'DummySessionProvider', [ 'canChangeUser' ] );
                $this->provider->expects( $this->any() )->method( 'canChangeUser' )
@@ -464,7 +464,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                // Save happens when delay is consumed
                $this->onSessionMetadataCalled = false;
                $priv->metaDirty = true;
-               \ScopedCallback::consume( $delay );
+               \Wikimedia\ScopedCallback::consume( $delay );
                $this->assertTrue( $this->onSessionMetadataCalled );
 
                // Test multiple delays
@@ -475,16 +475,16 @@ class SessionBackendTest extends MediaWikiTestCase {
                $priv->metaDirty = true;
                $priv->autosave();
                $this->assertFalse( $this->onSessionMetadataCalled );
-               \ScopedCallback::consume( $delay3 );
+               \Wikimedia\ScopedCallback::consume( $delay3 );
                $this->assertFalse( $this->onSessionMetadataCalled );
-               \ScopedCallback::consume( $delay1 );
+               \Wikimedia\ScopedCallback::consume( $delay1 );
                $this->assertFalse( $this->onSessionMetadataCalled );
-               \ScopedCallback::consume( $delay2 );
+               \Wikimedia\ScopedCallback::consume( $delay2 );
                $this->assertTrue( $this->onSessionMetadataCalled );
        }
 
        public function testSave() {
-               $user = User::newFromName( 'UTSysop' );
+               $user = static::getTestSysop()->getUser();
                $this->store = new TestBagOStuff();
                $testData = [ 'foo' => 'foo!', 'bar', [ 'baz', null ] ];
 
@@ -733,7 +733,7 @@ class SessionBackendTest extends MediaWikiTestCase {
        }
 
        public function testRenew() {
-               $user = User::newFromName( 'UTSysop' );
+               $user = static::getTestSysop()->getUser();
                $this->store = new TestBagOStuff();
                $testData = [ 'foo' => 'foo!', 'bar', [ 'baz', null ] ];
 
@@ -819,17 +819,17 @@ class SessionBackendTest extends MediaWikiTestCase {
                        PHPSessionHandler::install( SessionManager::singleton() );
                }
                if ( !PHPSessionHandler::isEnabled() ) {
-                       $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+                       $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
                        $rProp->setAccessible( true );
                        $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
-                       $resetHandler = new \ScopedCallback( function () use ( $handler ) {
+                       $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
                                session_write_close();
                                $handler->enable = false;
                        } );
                        $handler->enable = true;
                }
 
-               $backend = $this->getBackend( User::newFromName( 'UTSysop' ) );
+               $backend = $this->getBackend( static::getTestSysop()->getUser() );
                \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = true;
 
                $resetSingleton = TestUtils::setSessionManagerSingleton( $this->manager );
@@ -859,10 +859,10 @@ class SessionBackendTest extends MediaWikiTestCase {
                        PHPSessionHandler::install( SessionManager::singleton() );
                }
                if ( !PHPSessionHandler::isEnabled() ) {
-                       $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+                       $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
                        $rProp->setAccessible( true );
                        $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
-                       $resetHandler = new \ScopedCallback( function () use ( $handler ) {
+                       $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
                                session_write_close();
                                $handler->enable = false;
                        } );
@@ -895,10 +895,10 @@ class SessionBackendTest extends MediaWikiTestCase {
                        PHPSessionHandler::install( SessionManager::singleton() );
                }
                if ( !PHPSessionHandler::isEnabled() ) {
-                       $rProp = new \ReflectionProperty( 'MediaWiki\\Session\\PHPSessionHandler', 'instance' );
+                       $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' );
                        $rProp->setAccessible( true );
                        $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() );
-                       $resetHandler = new \ScopedCallback( function () use ( $handler ) {
+                       $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) {
                                session_write_close();
                                $handler->enable = false;
                        } );