@@ -96,40 +96,34 @@ public function testConstructorWithNullCredentials()
9696 public function testConstructorWithPasswordCredentials ()
9797 {
9898 // Test with password-only credentials
99- if ($ this ->getAuth ()) {
100- $ valkey_glide = new ValkeyGlideCluster (
101- [['host ' => '127.0.0.1 ' , 'port ' => 7001 ]],
102- false ,
103- $ this ->getAuth () // password credentials
104- );
99+ $ valkey_glide = new ValkeyGlideCluster (
100+ [['host ' => '127.0.0.1 ' , 'port ' => 5001 ]],
101+ false ,
102+ ['username ' => '' , 'password ' => 'dummy_password ' ] // password credentials
103+ );
105104
106- $ this ->assertTrue ($ valkey_glide ->ping (['type ' => 'primarySlotKey ' , 'key ' => 'test ' ]));
107- $ valkey_glide ->close ();
108- } else {
109- $ this ->markTestSkipped ('No authentication configured ' );
110- }
105+ $ this ->assertTrue ($ valkey_glide ->ping (['type ' => 'primarySlotKey ' , 'key ' => 'test ' ]));
106+ $ valkey_glide ->close ();
111107 }
112108
113109 public function testConstructorInvalidAuth ()
114110 {
115- if ($ this ->getAuth ()) {
116- // Test constructor with credentials (if auth is configured)
117- $ addresses = [
118- [['host ' => '127.0.0.1 ' , 'port ' => 7001 ]],
119- ];
120-
121- // Try to connect with incorrect auth
122- $ valkey_glide = null ;
123- try {
124- $ credentials = ['username ' => 'invalid_user ' , 'password ' => 'invalid_password ' ];
125- $ valkey_glide = new ValkeyGlideCluster ($ addresses , false , $ credentials );
126- $ this ->fail ("Should throw an exception when running commands with invalid authentication " );
127- } catch (Exception $ e ) {
128- $ this ->assertStringContains ("WRONGPASS " , $ e ->getMessage (), "Exception should indicate authentication failure " );
129- } finally {
130- // Clean up
131- $ valkey_glide ?->close();
132- }
111+ // Test constructor with credentials (if auth is configured)
112+ $ addresses = [
113+ [['host ' => '127.0.0.1 ' , 'port ' => 5001 ]],
114+ ];
115+
116+ // Try to connect with incorrect auth
117+ $ valkey_glide = null ;
118+ try {
119+ $ credentials = ['username ' => 'invalid_user ' , 'password ' => 'invalid_password ' ];
120+ $ valkey_glide = new ValkeyGlideCluster ($ addresses , false , $ credentials );
121+ $ this ->fail ("Should throw an exception when running commands with invalid authentication " );
122+ } catch (Exception $ e ) {
123+ $ this ->assertStringContains ("WRONGPASS " , $ e ->getMessage (), "Exception should indicate authentication failure " );
124+ } finally {
125+ // Clean up
126+ $ valkey_glide ?->close();
133127 }
134128 }
135129
0 commit comments