File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,24 +37,10 @@ protected function setUp(): void
3737 $ this ->handler = CacheFactory ::getHandler (new Cache (), 'memcached ' );
3838 }
3939
40- /**
41- * @return list<string>
42- */
43- private static function getKeyArray (): array
44- {
45- return [
46- self ::$ key1 ,
47- self ::$ key2 ,
48- self ::$ key3 ,
49- ];
50- }
51-
5240 protected function tearDown (): void
5341 {
5442 if (isset ($ this ->handler )) {
55- foreach (self ::getKeyArray () as $ key ) {
56- $ this ->handler ->delete ($ key );
57- }
43+ $ this ->handler ->clean ();
5844 }
5945
6046 parent ::tearDown ();
Original file line number Diff line number Diff line change @@ -35,25 +35,10 @@ protected function setUp(): void
3535 $ this ->handler = CacheFactory ::getHandler ($ this ->config , 'predis ' );
3636 }
3737
38- /**
39- * @return list<string>
40- */
41- private static function getKeyArray (): array
42- {
43- return [
44- self ::$ key1 ,
45- self ::$ key2 ,
46- self ::$ key3 ,
47- 'counter ' ,
48- ];
49- }
50-
5138 protected function tearDown (): void
5239 {
5340 if (isset ($ this ->handler )) {
54- foreach (self ::getKeyArray () as $ key ) {
55- $ this ->handler ->delete ($ key );
56- }
41+ $ this ->handler ->clean ();
5742 }
5843
5944 parent ::tearDown ();
Original file line number Diff line number Diff line change @@ -40,25 +40,10 @@ protected function setUp(): void
4040 $ this ->handler = CacheFactory ::getHandler ($ this ->config , 'redis ' );
4141 }
4242
43- /**
44- * @return list<string>
45- */
46- private static function getKeyArray (): array
47- {
48- return [
49- self ::$ key1 ,
50- self ::$ key2 ,
51- self ::$ key3 ,
52- 'counter ' ,
53- ];
54- }
55-
5643 protected function tearDown (): void
5744 {
5845 if (isset ($ this ->handler )) {
59- foreach (self ::getKeyArray () as $ key ) {
60- $ this ->handler ->delete ($ key );
61- }
46+ $ this ->handler ->clean ();
6247 }
6348
6449 parent ::tearDown ();
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ final class RedisHandlerTest extends CIUnitTestCase
3434{
3535 private string $ sessionDriver = RedisHandler::class;
3636 private string $ sessionName = 'ci_session ' ;
37- private string $ sessionSavePath = 'tcp://127.0.0.1:6379 ' ;
37+ private string $ sessionSavePath = 'tcp://127.0.0.1:6379?database=1 ' ;
3838 private string $ userIpAddress = '127.0.0.1 ' ;
3939
4040 /**
@@ -79,6 +79,7 @@ public static function tearDownAfterClass(): void
7979 try {
8080 $ redis = new Redis ();
8181 if ($ redis ->connect ('127.0.0.1 ' , 6379 , 1.0 )) {
82+ $ redis ->select (1 );
8283 $ keys = $ redis ->keys ('ci_session:* ' );
8384 if ($ keys !== false && $ keys !== []) {
8485 $ redis ->del ($ keys );
Original file line number Diff line number Diff line change 1818use CodeIgniter \Test \TestLogger ;
1919use Config \Logger as LoggerConfig ;
2020use Config \Session as SessionConfig ;
21- use Memcached ;
2221use PHPUnit \Framework \Attributes \Group ;
2322use PHPUnit \Framework \Attributes \RequiresPhpExtension ;
2423
@@ -61,28 +60,11 @@ protected function getInstance($options = []): MemcachedHandler
6160 return $ handler ;
6261 }
6362
64- protected function setUp (): void
65- {
66- parent ::setUp ();
67-
68- if (extension_loaded ('memcached ' )) {
69- $ memcached = new Memcached ();
70- $ memcached ->addServer ('127.0.0.1 ' , 11211 );
71- $ memcached ->flush ();
72- }
73- }
74-
7563 protected function tearDown (): void
7664 {
7765 parent ::tearDown ();
7866
7967 MemcachedHandler ::resetPersistentConnections ();
80-
81- if (extension_loaded ('memcached ' )) {
82- $ memcached = new Memcached ();
83- $ memcached ->addServer ('127.0.0.1 ' , 11211 );
84- $ memcached ->flush ();
85- }
8668 }
8769
8870 public function testConstructorThrowsWithEmptySavePath (): void
You can’t perform that action at this time.
0 commit comments