Merge "Fix wrong @return type hints in Language::tsTo… methods"
[lhc/web/wiklou.git] / tests / phpunit / includes / session / PHPSessionHandlerTest.php
index 64b16db..ce0f1b0 100644 (file)
@@ -23,7 +23,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                } );
                $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() );
@@ -31,7 +31,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                        $oldStore = $old->store;
                        $oldLogger = $old->logger;
                        $reset[] = new \ScopedCallback(
-                               [ 'MediaWiki\\Session\\PHPSessionHandler', 'install' ],
+                               [ PHPSessionHandler::class, 'install' ],
                                [ $oldManager, $oldStore, $oldLogger ]
                        );
                }
@@ -41,13 +41,13 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
 
        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 );
@@ -292,7 +292,9 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                // 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 ) {
@@ -300,12 +302,13 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                                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() {
@@ -322,9 +325,9 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
         * @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();
@@ -351,7 +354,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
         * @expectedExceptionMessageRegExp /: Wrong instance called!$/
         */
        public function testWrongInstance( $method, $args ) {
-               $handler = $this->getMockBuilder( 'MediaWiki\\Session\\PHPSessionHandler' )
+               $handler = $this->getMockBuilder( PHPSessionHandler::class )
                        ->setMethods( null )
                        ->disableOriginalConstructor()
                        ->getMock();