Remove a test case from PHPSessionHandlerTest::testSessionHandling()
authorOri Livneh <ori@wikimedia.org>
Wed, 18 May 2016 06:14:00 +0000 (23:14 -0700)
committerMZMcBride <w@mzmcbride.com>
Wed, 1 Jun 2016 04:46:41 +0000 (04:46 +0000)
The test sleeps for nine seconds (3 invocations, 3 seconds per
invocation) which is difficult to sit through.

The test code sets the value of two PHP parameters, session.gc_divisor
and session.gc_probability, to 1. This may be to ensure that PHP will
invoke the session handler's gc() method when the call is made to
session_start() below. But the call to PHPSessionHandler::gc() is
immaterial, for two reasons:

- PHPSessionHandler::gc() evicts items by calling the
  deleteObjectsExpiringBefore() on the BagOStuff instance it uses for
  storage. The only BagOStuff implementation that actually uses that
  method to evict items is SqlBagOStuff, which we're not using here,
  and which would be an odd choice of a storage backend for sessions.
- PHP calls SessionHandler::gc() _after_ opening the new (or resumed)
  session and loading its data, so even if deleteObjectsExpiringBefore()
  actually did anything, it would not influence the result of the test.

Bug: T135576
Change-Id: I6e153ec8bfa5972ed45a0e6b7720832692b952fb

tests/phpunit/includes/session/PHPSessionHandlerTest.php

index ce0f1b0..799a97b 100644 (file)
@@ -173,14 +173,6 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                        $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();