11<?php defined ('PHPREDIS_TESTRUN ' ) or die ('Use TestRedis.php to run tests!\n ' );
22
3- require_once ( dirname ( $ _SERVER [ ' PHP_SELF ' ]). '/TestSuite.php ' ) ;
4- require_once ( dirname ( $ _SERVER [ ' PHP_SELF ' ]). '/SessionHelpers.php ' ) ;
3+ require_once __DIR__ . '/TestSuite.php ' ;
4+ require_once __DIR__ . '/SessionHelpers.php ' ;
55
66class Redis_Test extends TestSuite {
77 /**
@@ -7223,7 +7223,15 @@ protected function sessionRunner() {
72237223 ->savePath ($ this ->sessionSavePath ());
72247224 }
72257225
7226+ protected function testRequiresMode (string $ mode ) {
7227+ if (php_sapi_name () != $ mode ) {
7228+ $ this ->markTestSkipped ("Test requires PHP running in ' $ mode' mode " );
7229+ }
7230+ }
7231+
72267232 public function testSession_compression () {
7233+ $ this ->testRequiresMode ('cli ' );
7234+
72277235 foreach ($ this ->getCompressors () as $ name => $ val ) {
72287236 $ data = "testing_compression_ $ name " ;
72297237
@@ -7244,6 +7252,8 @@ public function testSession_compression() {
72447252 }
72457253
72467254 public function testSession_savedToRedis () {
7255+ $ this ->testRequiresMode ('cli ' );
7256+
72477257 $ runner = $ this ->sessionRunner ();
72487258
72497259 $ this ->assertEquals ('SUCCESS ' , $ runner ->execFg ());
@@ -7260,6 +7270,8 @@ protected function sessionWaitSec() {
72607270 }
72617271
72627272 public function testSession_lockKeyCorrect () {
7273+ $ this ->testRequiresMode ('cli ' );
7274+
72637275 $ runner = $ this ->sessionRunner ()->sleep (5 );
72647276
72657277 $ this ->assertTrue ($ runner ->execBg ());
@@ -7272,6 +7284,8 @@ public function testSession_lockKeyCorrect() {
72727284 }
72737285
72747286 public function testSession_lockingDisabledByDefault () {
7287+ $ this ->testRequiresMode ('cli ' );
7288+
72757289 $ runner = $ this ->sessionRunner ()
72767290 ->lockingEnabled (false )
72777291 ->sleep (5 );
@@ -7281,6 +7295,8 @@ public function testSession_lockingDisabledByDefault() {
72817295 }
72827296
72837297 public function testSession_lockReleasedOnClose () {
7298+ $ this ->testRequiresMode ('cli ' );
7299+
72847300 $ runner = $ this ->sessionRunner ()
72857301 ->sleep (1 )
72867302 ->lockingEnabled (true );
@@ -7291,6 +7307,8 @@ public function testSession_lockReleasedOnClose() {
72917307 }
72927308
72937309 public function testSession_lock_ttlMaxExecutionTime () {
7310+ $ this ->testRequiresMode ('cli ' );
7311+
72947312 $ runner1 = $ this ->sessionRunner ()
72957313 ->sleep (10 )
72967314 ->maxExecutionTime (2 );
@@ -7309,6 +7327,7 @@ public function testSession_lock_ttlMaxExecutionTime() {
73097327 }
73107328
73117329 public function testSession_lock_ttlLockExpire () {
7330+ $ this ->testRequiresMode ('cli ' );
73127331
73137332 $ runner1 = $ this ->sessionRunner ()
73147333 ->sleep (10 )
@@ -7329,6 +7348,8 @@ public function testSession_lock_ttlLockExpire() {
73297348 }
73307349
73317350 public function testSession_lockHoldCheckBeforeWrite_otherProcessHasLock () {
7351+ $ this ->testRequiresMode ('cli ' );
7352+
73327353 $ id = 'test-id ' ;
73337354
73347355 $ runner = $ this ->sessionRunner ()
@@ -7352,6 +7373,8 @@ public function testSession_lockHoldCheckBeforeWrite_otherProcessHasLock() {
73527373 }
73537374
73547375 public function testSession_lockHoldCheckBeforeWrite_nobodyHasLock () {
7376+ $ this ->testRequiresMode ('cli ' );
7377+
73557378 $ runner = $ this ->sessionRunner ()
73567379 ->sleep (2 )
73577380 ->lockingEnabled (true )
@@ -7363,6 +7386,8 @@ public function testSession_lockHoldCheckBeforeWrite_nobodyHasLock() {
73637386 }
73647387
73657388 public function testSession_correctLockRetryCount () {
7389+ $ this ->testRequiresMode ('cli ' );
7390+
73667391 $ runner = $ this ->sessionRunner ()
73677392 ->sleep (10 );
73687393
@@ -7394,6 +7419,8 @@ public function testSession_correctLockRetryCount() {
73947419 }
73957420
73967421 public function testSession_defaultLockRetryCount () {
7422+ $ this ->testRequiresMode ('cli ' );
7423+
73977424 $ runner = $ this ->sessionRunner ()
73987425 ->sleep (10 );
73997426
@@ -7420,6 +7447,8 @@ public function testSession_defaultLockRetryCount() {
74207447 }
74217448
74227449 public function testSession_noUnlockOfOtherProcess () {
7450+ $ this ->testRequiresMode ('cli ' );
7451+
74237452 $ st = microtime (true );
74247453
74257454 $ sleep = 3 ;
@@ -7453,6 +7482,8 @@ public function testSession_noUnlockOfOtherProcess() {
74537482 }
74547483
74557484 public function testSession_lockWaitTime () {
7485+ $ this ->testRequiresMode ('cli ' );
7486+
74567487
74577488 $ runner = $ this ->sessionRunner ()
74587489 ->sleep (1 )
@@ -7603,6 +7634,8 @@ public function testBadOptionValue() {
76037634 }
76047635
76057636 protected function regenerateIdHelper (bool $ lock , bool $ destroy , bool $ proxy ) {
7637+ $ this ->testRequiresMode ('cli ' );
7638+
76067639 $ data = uniqid ('regenerate-id: ' );
76077640 $ runner = $ this ->sessionRunner ()
76087641 ->sleep (0 )
@@ -7652,12 +7685,16 @@ public function testSession_regenerateSessionId_withLock_withDestroy_withProxy(
76527685 }
76537686
76547687 public function testSession_ttl_equalsToSessionLifetime () {
7688+ $ this ->testRequiresMode ('cli ' );
7689+
76557690 $ runner = $ this ->sessionRunner ()->lifetime (600 );
76567691 $ this ->assertEquals ('SUCCESS ' , $ runner ->execFg ());
76577692 $ this ->assertEquals (600 , $ this ->redis ->ttl ($ runner ->getSessionKey ()));
76587693 }
76597694
76607695 public function testSession_ttl_resetOnWrite () {
7696+ $ this ->testRequiresMode ('cli ' );
7697+
76617698 $ runner1 = $ this ->sessionRunner ()->lifetime (600 );
76627699 $ this ->assertEquals ('SUCCESS ' , $ runner1 ->execFg ());
76637700
@@ -7668,6 +7705,8 @@ public function testSession_ttl_resetOnWrite() {
76687705 }
76697706
76707707 public function testSession_ttl_resetOnRead () {
7708+ $ this ->testRequiresMode ('cli ' );
7709+
76717710 $ data = uniqid (__FUNCTION__ );
76727711
76737712 $ runner = $ this ->sessionRunner ()->lifetime (600 )->data ($ data );
0 commit comments