@@ -14,7 +14,7 @@ final class ClientTest extends TestCase
1414
1515 public function testARecords (): void
1616 {
17- $ client = new Client ('localhost ' , self ::PORT );
17+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
1818 $ response = $ client ->query (Message::query (
1919 new Question ('dev.appwrite.io ' , Record::TYPE_A )
2020 ));
@@ -49,7 +49,7 @@ public function testARecords(): void
4949
5050 public function testAAAARecords (): void
5151 {
52- $ client = new Client ('localhost ' , self ::PORT );
52+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
5353 $ response = $ client ->query (Message::query (
5454 new Question ('dev.appwrite.io ' , Record::TYPE_AAAA )
5555 ));
@@ -79,7 +79,7 @@ public function testAAAARecords(): void
7979
8080 public function testCnameRecords (): void
8181 {
82- $ client = new Client ('localhost ' , self ::PORT );
82+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
8383 $ response = $ client ->query (Message::query (
8484 new Question ('alias.appwrite.io ' , Record::TYPE_CNAME )
8585 ));
@@ -102,7 +102,7 @@ public function testCnameRecords(): void
102102
103103 public function testTxtRecords (): void
104104 {
105- $ client = new Client ('localhost ' , self ::PORT );
105+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
106106 $ response = $ client ->query (Message::query (
107107 new Question ('dev.appwrite.io ' , Record::TYPE_TXT )
108108 ));
@@ -128,7 +128,7 @@ public function testTxtRecords(): void
128128
129129 public function testNsRecords (): void
130130 {
131- $ client = new Client ('localhost ' , self ::PORT );
131+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
132132 $ response = $ client ->query (Message::query (
133133 new Question ('delegated.appwrite.io ' , Record::TYPE_NS )
134134 ));
@@ -161,7 +161,7 @@ public function testNsRecords(): void
161161
162162 public function testCaaRecords (): void
163163 {
164- $ client = new Client ('localhost ' , self ::PORT );
164+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
165165 $ response = $ client ->query (Message::query (
166166 new Question ('dev.appwrite.io ' , Record::TYPE_CAA )
167167 ));
@@ -187,7 +187,7 @@ public function testCaaRecords(): void
187187
188188 public function testSoaRecords (): void
189189 {
190- $ client = new Client ('localhost ' , self ::PORT );
190+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
191191 $ response = $ client ->query (Message::query (
192192 new Question ('appwrite.io ' , Record::TYPE_SOA )
193193 ));
@@ -220,4 +220,39 @@ public function testSoaRecords(): void
220220 $ this ->assertStringContainsString ('team.appwrite.io ' , $ rdata );
221221 $ this ->assertStringContainsString ('1 7200 1800 1209600 3600 ' , $ rdata );
222222 }
223+
224+ public function testInvalidServer (): void
225+ {
226+ try {
227+ new Client ('not-ip-address ' , self ::PORT );
228+ $ this ->fail ('Expected invalid IP address exception ' );
229+ } catch (\Exception $ e ) {
230+ $ this ->assertEquals ('Server must be an IP address. ' , $ e ->getMessage ());
231+ }
232+
233+ try {
234+ new Client ('ns1.digitalocean.com ' , self ::PORT );
235+ $ this ->fail ('Expected invalid IP address exception ' );
236+ } catch (\Exception $ e ) {
237+ $ this ->assertEquals ('Server must be an IP address. ' , $ e ->getMessage ());
238+ }
239+
240+ try {
241+ $ client = new Client ('172.64.52.210 ' , self ::PORT );
242+ $ this ->assertNotEmpty ($ client );
243+ $ client = new Client ('127.0.0.1 ' , self ::PORT );
244+ $ this ->assertNotEmpty ($ client );
245+ } catch (\Exception $ e ) {
246+ $ this ->fail ('IPv4 threw unexpected error ' );
247+ }
248+
249+ try {
250+ $ client = new Client ('::1 ' , self ::PORT );
251+ $ this ->assertNotEmpty ($ client );
252+ $ client = new Client ('2606:4700:52::ac40:34d2 ' , self ::PORT );
253+ $ this ->assertNotEmpty ($ client );
254+ } catch (\Exception $ e ) {
255+ $ this ->fail ('IPv6 threw unexpected error ' );
256+ }
257+ }
223258}
0 commit comments