@@ -5274,7 +5274,8 @@ public function testSession_lockWaitTime()
5274
5274
$ end = microtime (true );
5275
5275
$ elapsedTime = $ end - $ start ;
5276
5276
5277
- $ this ->assertTrue ($ elapsedTime > 2.5 && $ elapsedTime < 3.5 );
5277
+ $ this ->assertTrue ($ elapsedTime > 2.5 );
5278
+ $ this ->assertTrue ($ elapsedTime < 3.5 );
5278
5279
$ this ->assertTrue ($ sessionSuccessful );
5279
5280
}
5280
5281
@@ -5288,6 +5289,110 @@ public function testMultipleConnect() {
5288
5289
}
5289
5290
}
5290
5291
5292
+ public function testSession_regenerateSessionId_noLock_noDestroy () {
5293
+ $ this ->setSessionHandler ();
5294
+ $ sessionId = $ this ->generateSessionId ();
5295
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5296
+
5297
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId );
5298
+
5299
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5300
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5301
+ }
5302
+
5303
+ public function testSession_regenerateSessionId_noLock_withDestroy () {
5304
+ $ this ->setSessionHandler ();
5305
+ $ sessionId = $ this ->generateSessionId ();
5306
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5307
+
5308
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , false , true );
5309
+
5310
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5311
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5312
+ }
5313
+
5314
+ public function testSession_regenerateSessionId_withLock_noDestroy () {
5315
+ $ this ->setSessionHandler ();
5316
+ $ sessionId = $ this ->generateSessionId ();
5317
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5318
+
5319
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , true );
5320
+
5321
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5322
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5323
+ }
5324
+
5325
+ public function testSession_regenerateSessionId_withLock_withDestroy () {
5326
+ $ this ->setSessionHandler ();
5327
+ $ sessionId = $ this ->generateSessionId ();
5328
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5329
+
5330
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , true , true );
5331
+
5332
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5333
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5334
+ }
5335
+
5336
+ public function testSession_regenerateSessionId_noLock_noDestroy_withProxy () {
5337
+ if (!interface_exists ('SessionHandlerInterface ' )) {
5338
+ $ this ->markTestSkipped ('session handler interface not available in PHP < 5.4 ' );
5339
+ }
5340
+
5341
+ $ this ->setSessionHandler ();
5342
+ $ sessionId = $ this ->generateSessionId ();
5343
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5344
+
5345
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , false , false , true );
5346
+
5347
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5348
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5349
+ }
5350
+
5351
+ public function testSession_regenerateSessionId_noLock_withDestroy_withProxy () {
5352
+ if (!interface_exists ('SessionHandlerInterface ' )) {
5353
+ $ this ->markTestSkipped ('session handler interface not available in PHP < 5.4 ' );
5354
+ }
5355
+
5356
+ $ this ->setSessionHandler ();
5357
+ $ sessionId = $ this ->generateSessionId ();
5358
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5359
+
5360
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , false , true , true );
5361
+
5362
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5363
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5364
+ }
5365
+
5366
+ public function testSession_regenerateSessionId_withLock_noDestroy_withProxy () {
5367
+ if (!interface_exists ('SessionHandlerInterface ' )) {
5368
+ $ this ->markTestSkipped ('session handler interface not available in PHP < 5.4 ' );
5369
+ }
5370
+
5371
+ $ this ->setSessionHandler ();
5372
+ $ sessionId = $ this ->generateSessionId ();
5373
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5374
+
5375
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , true , false , true );
5376
+
5377
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5378
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5379
+ }
5380
+
5381
+ public function testSession_regenerateSessionId_withLock_withDestroy_withProxy () {
5382
+ if (!interface_exists ('SessionHandlerInterface ' )) {
5383
+ $ this ->markTestSkipped ('session handler interface not available in PHP < 5.4 ' );
5384
+ }
5385
+
5386
+ $ this ->setSessionHandler ();
5387
+ $ sessionId = $ this ->generateSessionId ();
5388
+ $ this ->startSessionProcess ($ sessionId , 0 , false , 300 , true , null , -1 , 1 , 'bar ' );
5389
+
5390
+ $ newSessionId = $ this ->regenerateSessionId ($ sessionId , true , true , true );
5391
+
5392
+ $ this ->assertTrue ($ newSessionId !== $ sessionId );
5393
+ $ this ->assertEquals ('bar ' , $ this ->getSessionData ($ newSessionId ));
5394
+ }
5395
+
5291
5396
private function setSessionHandler ()
5292
5397
{
5293
5398
$ host = $ this ->getHost () ?: 'localhost ' ;
@@ -5358,5 +5463,24 @@ private function getSessionData($sessionId)
5358
5463
5359
5464
return $ output [0 ];
5360
5465
}
5466
+
5467
+ /**
5468
+ * @param string $sessionId
5469
+ * @param bool $locking
5470
+ * @param bool $destroyPrevious
5471
+ * @param bool $sessionProxy
5472
+ *
5473
+ * @return string
5474
+ */
5475
+ private function regenerateSessionId ($ sessionId , $ locking = false , $ destroyPrevious = false , $ sessionProxy = false )
5476
+ {
5477
+ $ args = array_map ('escapeshellarg ' , array ($ sessionId , $ locking , $ destroyPrevious , $ sessionProxy ));
5478
+
5479
+ $ command = 'php --no-php-ini --define extension=igbinary.so --define extension= ' . __DIR__ . '/../modules/redis.so ' . __DIR__ . '/regenerateSessionId.php ' . escapeshellarg ($ this ->getHost ()) . ' ' . implode (' ' , $ args );
5480
+
5481
+ exec ($ command , $ output );
5482
+
5483
+ return $ output [0 ];
5484
+ }
5361
5485
}
5362
5486
?>
0 commit comments