@@ -5217,7 +5217,7 @@ public function testSession_lockReleasedOnClose()
52175217 $ this ->assertFalse ($ this ->redis ->exists ($ this ->sessionPrefix . $ sessionId . '_LOCK ' ));
52185218 }
52195219
5220- public function testSession_ttlMaxExecutionTime ()
5220+ public function testSession_lock_ttlMaxExecutionTime ()
52215221 {
52225222 $ this ->setSessionHandler ();
52235223 $ sessionId = $ this ->generateSessionId ();
@@ -5233,7 +5233,7 @@ public function testSession_ttlMaxExecutionTime()
52335233 $ this ->assertTrue ($ sessionSuccessful );
52345234 }
52355235
5236- public function testSession_ttlLockExpire ()
5236+ public function testSession_lock_ttlLockExpire ()
52375237 {
52385238 $ this ->setSessionHandler ();
52395239 $ sessionId = $ this ->generateSessionId ();
@@ -5468,6 +5468,37 @@ public function testSession_regenerateSessionId_withLock_withDestroy_withProxy(
54685468 $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
54695469 }
54705470
5471+ public function testSession_ttl_equalsToSessionLifetime ()
5472+ {
5473+ $ sessionId = $ this ->generateSessionId ();
5474+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 0 , 'test ' , 600 );
5475+ $ ttl = $ this ->redis ->ttl ($ this ->sessionPrefix . $ sessionId );
5476+
5477+ $ this ->assertEquals (600 , $ ttl );
5478+ }
5479+
5480+ public function testSession_ttl_resetOnWrite ()
5481+ {
5482+ $ sessionId = $ this ->generateSessionId ();
5483+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 0 , 'test ' , 600 );
5484+ $ this ->redis ->expire ($ this ->sessionPrefix . $ sessionId , 9999 );
5485+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 0 , 'test ' , 600 );
5486+ $ ttl = $ this ->redis ->ttl ($ this ->sessionPrefix . $ sessionId );
5487+
5488+ $ this ->assertEquals (600 , $ ttl );
5489+ }
5490+
5491+ public function testSession_ttl_resetOnRead ()
5492+ {
5493+ $ sessionId = $ this ->generateSessionId ();
5494+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 0 , 'test ' , 600 );
5495+ $ this ->redis ->expire ($ this ->sessionPrefix . $ sessionId , 9999 );
5496+ $ this ->getSessionData ($ sessionId );
5497+ $ ttl = $ this ->redis ->ttl ($ this ->sessionPrefix . $ sessionId );
5498+
5499+ $ this ->assertEquals (600 , $ ttl );
5500+ }
5501+
54715502 private function setSessionHandler ()
54725503 {
54735504 $ host = $ this ->getHost () ?: 'localhost ' ;
@@ -5503,15 +5534,18 @@ private function generateSessionId()
55035534 * @param int $lock_expires
55045535 * @param string $sessionData
55055536 *
5537+ * @param int $sessionLifetime
5538+ *
55065539 * @return bool
5540+ * @throws Exception
55075541 */
5508- private function startSessionProcess ($ sessionId , $ sleepTime , $ background , $ maxExecutionTime = 300 , $ locking_enabled = true , $ lock_wait_time = null , $ lock_retries = -1 , $ lock_expires = 0 , $ sessionData = '' )
5542+ private function startSessionProcess ($ sessionId , $ sleepTime , $ background , $ maxExecutionTime = 300 , $ locking_enabled = true , $ lock_wait_time = null , $ lock_retries = -1 , $ lock_expires = 0 , $ sessionData = '' , $ sessionLifetime = 1440 )
55095543 {
55105544 if (substr (php_uname (), 0 , 7 ) == "Windows " ){
55115545 $ this ->markTestSkipped ();
55125546 return true ;
55135547 } else {
5514- $ commandParameters = array ($ this ->getHost (), $ sessionId , $ sleepTime , $ maxExecutionTime , $ lock_retries , $ lock_expires , $ sessionData );
5548+ $ commandParameters = array ($ this ->getHost (), $ sessionId , $ sleepTime , $ maxExecutionTime , $ lock_retries , $ lock_expires , $ sessionData, $ sessionLifetime );
55155549 if ($ locking_enabled ) {
55165550 $ commandParameters [] = '1 ' ;
55175551
0 commit comments