@@ -116,18 +116,30 @@ public function testWait()
116116 {
117117 $ this ->markTestSkipped ();
118118 }
119+
119120 public function testSelect ()
120121 {
121- $ this ->markTestSkipped ();
122+ $ this ->assertFalse (@$ this ->valkey_glide ->select (-1 ));
123+ $ this ->assertTrue ($ this ->valkey_glide ->select (0 ));
122124 }
123- public function testReconnectSelect ()
125+
126+ public function testMove ()
124127 {
125- $ this ->markTestSkipped ();
128+ // Basic MOVE method availability test
129+ $ key = '{key}test_move_ ' . uniqid ();
130+ $ this ->valkey_glide ->set ($ key , 'test_value ' );
131+
132+ // MOVE should return boolean (may be false if multi-database not supported)
133+ $ result = $ this ->valkey_glide ->move ($ key , 1 );
134+ $ this ->assertIsBool ($ result );
135+
136+ // Clean up
137+ $ this ->valkey_glide ->del ($ key );
126138 }
127139
128- public function testMove ()
140+ public function testReconnectSelect ()
129141 {
130- $ this ->markTestSkipped (); // Move is not supported in ValkeyGlideCluster
142+ $ this ->markTestSkipped ();
131143 }
132144
133145 /* These 'directed node' commands work differently in ValkeyGlideCluster */
@@ -199,6 +211,14 @@ protected function newInstance()
199211 false , // use_tls
200212 $ this ->getAuth (), // credentials
201213 ValkeyGlide::READ_FROM_PRIMARY , // read_from
214+ null , // request_timeout
215+ null , // reconnect_strategy
216+ null , // client_name
217+ null , // periodic_checks
218+ null , // client_az
219+ null , // advanced_config
220+ null , // lazy_connect
221+ 0 // database_id - enable multi-database support
202222 );
203223 } catch (Exception $ ex ) {
204224 TestSuite::errorMessage ("Fatal error: %s \n" , $ ex ->getMessage ());
@@ -905,4 +925,141 @@ public function testReplyLiteral()
905925 // Reset
906926 $ this ->valkey_glide ->setOption (ValkeyGlide::OPT_REPLY_LITERAL , false );
907927 }
928+
929+ public function testCopyCluster ()
930+ {
931+ if (version_compare ($ this ->version , '6.2.0 ' ) < 0 ) {
932+ $ this ->markTestSkipped ('COPY command requires Valkey 6.2.0+ ' );
933+ }
934+
935+ $ this ->valkey_glide ->del ('{key}dst ' );
936+ $ this ->valkey_glide ->set ('{key}src ' , 'foo ' );
937+ $ this ->assertTrue ($ this ->valkey_glide ->copy ('{key}src ' , '{key}dst ' ));
938+ $ this ->assertKeyEquals ('foo ' , '{key}dst ' );
939+
940+ $ this ->valkey_glide ->set ('{key}src ' , 'bar ' );
941+ $ this ->assertFalse ($ this ->valkey_glide ->copy ('{key}src ' , '{key}dst ' ));
942+ $ this ->assertKeyEquals ('foo ' , '{key}dst ' );
943+
944+ $ this ->assertTrue ($ this ->valkey_glide ->copy ('{key}src ' , '{key}dst ' , ['REPLACE ' => true ]));
945+ $ this ->assertKeyEquals ('bar ' , '{key}dst ' );
946+ }
947+
948+ public function testCopyClusterWithDatabase ()
949+ {
950+ if (version_compare ($ this ->version , '9.0.0 ' ) < 0 ) {
951+ $ this ->markTestSkipped ('COPY with database ID in cluster mode requires Valkey 9.0.0+ ' );
952+ }
953+
954+ // Test copy to different database in cluster mode
955+ $ this ->valkey_glide ->del ('{key}src ' , '{key}dst ' );
956+ $ this ->valkey_glide ->set ('{key}src ' , 'cluster_test_value ' );
957+
958+ // Test with string key
959+ $ this ->assertTrue ($ this ->valkey_glide ->copy ('{key}src ' , '{key}dst ' , ['DB ' => 1 ]));
960+
961+ // Test with constant
962+ $ this ->valkey_glide ->set ('{key}src2 ' , 'cluster_constant_test ' );
963+ $ this ->assertTrue ($ this ->valkey_glide ->copy ('{key}src2 ' , '{key}dst2 ' , [ValkeyGlide::COPY_DB => 1 ]));
964+
965+ // Test combined options
966+ $ this ->assertTrue ($ this ->valkey_glide ->copy ('{key}src ' , '{key}dst ' , [
967+ ValkeyGlide::COPY_DB => 1 ,
968+ ValkeyGlide::COPY_REPLACE => true
969+ ]));
970+ }
971+
972+ public function testSelectMultipleDatabase ()
973+ {
974+ if (version_compare ($ this ->version , '9.0.0 ' ) < 0 ) {
975+ $ this ->markTestSkipped ('Multi-database operations in cluster mode require Valkey 9.0.0+ ' );
976+ }
977+
978+ // SELECT should work in Valkey 9.0+ clusters
979+ $ this ->assertTrue ($ this ->valkey_glide ->select (0 ));
980+ $ this ->assertTrue ($ this ->valkey_glide ->select (1 ));
981+ $ this ->assertTrue ($ this ->valkey_glide ->select (2 ));
982+ $ this ->assertTrue ($ this ->valkey_glide ->select (15 ));
983+ $ this ->assertFalse (@$ this ->valkey_glide ->select (-1 ));
984+ $ this ->assertTrue ($ this ->valkey_glide ->select (0 ));
985+ }
986+
987+ public function testDatabaseIsolation ()
988+ {
989+ if (version_compare ($ this ->version , '9.0.0 ' ) < 0 ) {
990+ $ this ->markTestSkipped ('Multi-database operations in cluster mode require Valkey 9.0.0+ ' );
991+ }
992+
993+ $ key = '{key}isolation_test_ ' . uniqid ();
994+
995+ $ this ->valkey_glide ->select (0 );
996+ $ this ->valkey_glide ->set ($ key , 'value_db0 ' );
997+ $ this ->valkey_glide ->select (1 );
998+ $ this ->valkey_glide ->set ($ key , 'value_db1 ' );
999+
1000+ $ this ->valkey_glide ->select (0 );
1001+ $ this ->assertEquals ('value_db0 ' , $ this ->valkey_glide ->get ($ key ));
1002+ $ this ->valkey_glide ->select (1 );
1003+ $ this ->assertEquals ('value_db1 ' , $ this ->valkey_glide ->get ($ key ));
1004+
1005+ // Clean up
1006+ $ this ->valkey_glide ->del ($ key );
1007+ $ this ->valkey_glide ->select (0 );
1008+ $ this ->valkey_glide ->del ($ key );
1009+ }
1010+
1011+ public function testMoveMultiDatabase ()
1012+ {
1013+ if (version_compare ($ this ->version , '9.0.0 ' ) < 0 ) {
1014+ $ this ->markTestSkipped ('Multi-database MOVE in cluster mode requires Valkey 9.0.0+ ' );
1015+ }
1016+
1017+ $ key = '{key}move_test_ ' . uniqid ();
1018+
1019+ $ this ->valkey_glide ->select (0 );
1020+ $ this ->valkey_glide ->set ($ key , 'move_test_value ' );
1021+
1022+ // In Valkey 9.0+, MOVE should succeed - failure indicates missing cluster-databases config
1023+ $ result = $ this ->valkey_glide ->move ($ key , 1 );
1024+ $ this ->assertTrue ($ result , 'MOVE should succeed in Valkey 9.0+ cluster (ensure cluster-databases > 1 is configured) ' );
1025+
1026+ // Verify MOVE worked correctly
1027+ $ this ->assertEquals (0 , $ this ->valkey_glide ->exists ($ key )); // Should not exist in DB 0
1028+
1029+ $ this ->valkey_glide ->select (1 );
1030+ $ this ->assertEquals (1 , $ this ->valkey_glide ->exists ($ key )); // Should exist in DB 1
1031+ $ this ->assertEquals ('move_test_value ' , $ this ->valkey_glide ->get ($ key ));
1032+
1033+ // Clean up
1034+ $ this ->valkey_glide ->del ($ key );
1035+ $ this ->valkey_glide ->select (0 );
1036+ }
1037+
1038+ public function testCopyMultiDatabase ()
1039+ {
1040+ if (version_compare ($ this ->version , '9.0.0 ' ) < 0 ) {
1041+ $ this ->markTestSkipped ('Multi-database COPY in cluster mode requires Valkey 9.0.0+ ' );
1042+ }
1043+
1044+ $ srcKey = '{key}copy_src_ ' . uniqid ();
1045+ $ dstKey = '{key}copy_dst_ ' . uniqid ();
1046+
1047+ $ this ->valkey_glide ->select (0 );
1048+ $ this ->valkey_glide ->set ($ srcKey , 'copy_test_value ' );
1049+
1050+ // COPY with DB parameter should work in Valkey 9.0+ clusters
1051+ $ result = $ this ->valkey_glide ->copy ($ srcKey , $ dstKey , ['DB ' => 1 ]);
1052+ $ this ->assertTrue ($ result , 'COPY should succeed in Valkey 9.0+ cluster ' );
1053+
1054+ // Verify COPY worked correctly
1055+ $ this ->assertEquals ('copy_test_value ' , $ this ->valkey_glide ->get ($ srcKey )); // Original still exists
1056+
1057+ $ this ->valkey_glide ->select (1 );
1058+ $ this ->assertEquals ('copy_test_value ' , $ this ->valkey_glide ->get ($ dstKey )); // Copy exists
1059+
1060+ // Clean up
1061+ $ this ->valkey_glide ->del ($ dstKey );
1062+ $ this ->valkey_glide ->select (0 );
1063+ $ this ->valkey_glide ->del ($ srcKey );
1064+ }
9081065}
0 commit comments