@@ -26,10 +26,7 @@ protected function setUp(): void
2626
2727 public function testCmdsHash (): void
2828 {
29- echo "\n=== Testing Redis Hash Commands === \n" ;
30-
3129 // STEP_START hdel
32- echo "\n--- HDEL Command --- \n" ;
3330 $ hDelResult1 = $ this ->redis ->hset ('myhash ' , 'field1 ' , 'foo ' );
3431 echo "HSET myhash field1 foo: " . $ hDelResult1 . "\n" ; // >>> 1
3532
@@ -40,12 +37,13 @@ public function testCmdsHash(): void
4037 echo "HDEL myhash field2: " . $ hDelResult3 . "\n" ; // >>> 0
4138 // STEP_END
4239
40+ // REMOVE_START
4341 $ this ->assertEquals (1 , $ hDelResult1 );
4442 $ this ->assertEquals (1 , $ hDelResult2 );
4543 $ this ->assertEquals (0 , $ hDelResult3 );
44+ // REMOVE_END
4645
4746 // STEP_START hget
48- echo "\n--- HGET Command --- \n" ;
4947 $ hGetResult1 = $ this ->redis ->hset ('myhash ' , 'field1 ' , 'foo ' );
5048 echo "HSET myhash field1 foo: " . $ hGetResult1 . "\n" ; // >>> 1
5149
@@ -56,26 +54,29 @@ public function testCmdsHash(): void
5654 echo "HGET myhash field2: " . ($ hGetResult3 ?? 'null ' ) . "\n" ; // >>> null
5755 // STEP_END
5856
57+ // REMOVE_START
5958 $ this ->assertEquals (1 , $ hGetResult1 );
6059 $ this ->assertEquals ('foo ' , $ hGetResult2 );
6160 $ this ->assertNull ($ hGetResult3 );
61+ // REMOVE_END
6262
6363 // STEP_START hgetall
64- echo "\n--- HGETALL Command --- \n" ;
6564 $ hGetAllResult1 = $ this ->redis ->hmset ('myhash ' , ['field1 ' => 'Hello ' , 'field2 ' => 'World ' ]);
6665 echo "HMSET myhash field1 Hello field2 World: " . ($ hGetAllResult1 ? 'OK ' : 'FAIL ' ) . "\n" ; // >>> OK
6766
6867 $ hGetAllResult2 = $ this ->redis ->hgetall ('myhash ' );
6968 echo "HGETALL myhash: " . json_encode ($ hGetAllResult2 ) . "\n" ; // >>> {"field1":"Hello","field2":"World"}
7069 // STEP_END
7170
71+ // REMOVE_START
7272 $ this ->assertEquals ('OK ' , $ hGetAllResult1 );
7373 $ this ->assertEquals (['field1 ' => 'Hello ' , 'field2 ' => 'World ' ], $ hGetAllResult2 );
74+ // REMOVE_END
7475
7576 // STEP_START hset
76- echo "\n--- HSET Command --- \n" ;
77- // Clean up first
77+ // REMOVE_START
7878 $ this ->redis ->del ('myhash ' );
79+ // REMOVE_END
7980
8081 $ hSetResult1 = $ this ->redis ->hset ('myhash ' , 'field1 ' , 'Hello ' );
8182 echo "HSET myhash field1 Hello: " . $ hSetResult1 . "\n" ; // >>> 1
@@ -100,17 +101,19 @@ public function testCmdsHash(): void
100101 echo "\n" ;
101102 // STEP_END
102103
104+ // REMOVE_START
103105 $ this ->assertEquals (1 , $ hSetResult1 );
104106 $ this ->assertEquals ('Hello ' , $ hSetResult2 );
105107 $ this ->assertEquals ('OK ' , $ hSetResult3 );
106108 $ this ->assertEquals ('Hi ' , $ hSetResult4 );
107109 $ this ->assertEquals ('World ' , $ hSetResult5 );
108110 $ this ->assertEquals (['field1 ' => 'Hello ' , 'field2 ' => 'Hi ' , 'field3 ' => 'World ' ], $ hSetResult6 );
111+ // REMOVE_END
109112
110113 // STEP_START hvals
111- echo "\n--- HVALS Command --- \n" ;
112- // Clean up first
114+ // REMOVE_START
113115 $ this ->redis ->del ('myhash ' );
116+ // REMOVE_END
114117
115118 $ hValsResult1 = $ this ->redis ->hmset ('myhash ' , ['field1 ' => 'Hello ' , 'field2 ' => 'World ' ]);
116119 echo "HMSET myhash field1 Hello field2 World: " . ($ hValsResult1 ? 'OK ' : 'FAIL ' ) . "\n" ; // >>> OK
@@ -119,13 +122,15 @@ public function testCmdsHash(): void
119122 echo "HVALS myhash: " . json_encode ($ hValsResult2 ) . "\n" ; // >>> ["Hello","World"]
120123 // STEP_END
121124
125+ // REMOVE_START
122126 $ this ->assertEquals ('OK ' , $ hValsResult1 );
123127 $ this ->assertEquals (['Hello ' , 'World ' ], $ hValsResult2 );
128+ // REMOVE_END
124129
125130 // STEP_START hexpire
126- echo "\n--- HEXPIRE Command --- \n" ;
127- // Clean up first
131+ // REMOVE_START
128132 $ this ->redis ->del ('myhash ' );
133+ // REMOVE_END
129134
130135 // Set up hash with fields
131136 $ hExpireResult1 = $ this ->redis ->hmset ('myhash ' , ['field1 ' => 'Hello ' , 'field2 ' => 'World ' ]);
@@ -144,13 +149,13 @@ public function testCmdsHash(): void
144149 echo "HEXPIRE myhash 10 FIELDS nonexistent: " . json_encode ($ hExpireResult4 ) . "\n" ; // >>> [-2]
145150 // STEP_END
146151
152+ // REMOVE_START
147153 $ this ->assertEquals ('OK ' , $ hExpireResult1 );
148154 $ this ->assertEquals ([1 , 1 ], $ hExpireResult2 );
149155 $ this ->assertEquals (2 , count ($ hExpireResult3 ));
150156 $ this ->assertTrue (array_reduce ($ hExpireResult3 , function ($ carry , $ ttl ) { return $ carry && $ ttl > 0 ; }, true )); // TTL should be positive
151157 $ this ->assertEquals ([-2 ], $ hExpireResult4 );
152-
153- echo "\n=== All Hash Commands Tests Passed! === \n" ;
158+ // REMOVE_END
154159 }
155160
156161 protected function tearDown (): void
0 commit comments