@@ -35,27 +35,27 @@ public static function provideDefaultPortProvider()
3535 return array (
3636 array (
3737 '8.8.8.8 ' ,
38- '8.8.8.8:53 '
38+ 'tcp:// 8.8.8.8:53 '
3939 ),
4040 array (
4141 '1.2.3.4:5 ' ,
42- '1.2.3.4:5 '
42+ 'tcp:// 1.2.3.4:5 '
4343 ),
4444 array (
4545 'tcp://1.2.3.4 ' ,
46- '1.2.3.4:53 '
46+ 'tcp:// 1.2.3.4:53 '
4747 ),
4848 array (
4949 'tcp://1.2.3.4:53 ' ,
50- '1.2.3.4:53 '
50+ 'tcp:// 1.2.3.4:53 '
5151 ),
5252 array (
5353 '::1 ' ,
54- '[::1]:53 '
54+ 'tcp:// [::1]:53 '
5555 ),
5656 array (
5757 '[::1]:53 ' ,
58- '[::1]:53 '
58+ 'tcp:// [::1]:53 '
5959 )
6060 );
6161 }
@@ -129,7 +129,7 @@ public function testQueryRejectsIfServerConnectionFails()
129129
130130 /** @var \RuntimeException $exception */
131131 $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
132- $ this ->assertEquals ('DNS query for google.com (A) failed: Unable to connect to DNS server (Failed to parse address "///") ' , $ exception ->getMessage ());
132+ $ this ->assertEquals ('DNS query for google.com (A) failed: Unable to connect to DNS server /// (Failed to parse address "///") ' , $ exception ->getMessage ());
133133 }
134134
135135 public function testQueryRejectsOnCancellationWithoutClosingSocketButStartsIdleTimer ()
@@ -265,7 +265,7 @@ function ($e) use (&$exception) {
265265
266266 /** @var \RuntimeException $exception */
267267 $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
268- $ this ->assertEquals ('DNS query for google.com (A) failed: Connection to DNS server rejected ' , $ exception ->getMessage ());
268+ $ this ->assertEquals ('DNS query for google.com (A) failed: Connection to DNS server tcp://127.0.0.1:1 rejected ' , $ exception ->getMessage ());
269269 }
270270
271271 public function testQueryStaysPendingWhenClientCanNotSendExcessiveMessageInOneChunk ()
@@ -390,7 +390,7 @@ public function testQueryRejectsWhenClientKeepsSendingWhenServerClosesSocket()
390390 // expect EPIPE (Broken pipe), except for macOS kernel race condition or legacy HHVM
391391 $ this ->setExpectedException (
392392 'RuntimeException ' ,
393- 'Unable to send query to DNS server ' ,
393+ 'Unable to send query to DNS server tcp:// ' . $ address . ' ( ' ,
394394 defined ('SOCKET_EPIPE ' ) && !defined ('HHVM_VERSION ' ) ? (PHP_OS !== 'Darwin ' || $ writePending ? SOCKET_EPIPE : SOCKET_EPROTOTYPE ) : null
395395 );
396396 throw $ exception ;
@@ -411,21 +411,22 @@ public function testQueryRejectsWhenServerClosesConnection()
411411
412412 $ query = new Query ('google.com ' , Message::TYPE_A , Message::CLASS_IN );
413413
414- $ wait = true ;
414+ $ exception = null ;
415415 $ executor ->query ($ query )->then (
416416 null ,
417- function ($ e ) use (&$ wait ) {
418- $ wait = false ;
419- throw $ e ;
417+ function ($ e ) use (&$ exception ) {
418+ $ exception = $ e ;
420419 }
421420 );
422421
423422 \Clue \React \Block \sleep (0.01 , $ loop );
424- if ($ wait ) {
423+ if ($ exception === null ) {
425424 \Clue \React \Block \sleep (0.2 , $ loop );
426425 }
427426
428- $ this ->assertFalse ($ wait );
427+ /** @var \RuntimeException $exception */
428+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
429+ $ this ->assertEquals ('DNS query for google.com (A) failed: Connection to DNS server tcp:// ' . $ address . ' lost ' , $ exception ->getMessage ());
429430 }
430431
431432 public function testQueryKeepsPendingIfServerSendsIncompleteMessageLength ()
@@ -514,21 +515,22 @@ public function testQueryRejectsWhenServerSendsInvalidMessage()
514515
515516 $ query = new Query ('google.com ' , Message::TYPE_A , Message::CLASS_IN );
516517
517- $ wait = true ;
518+ $ exception = null ;
518519 $ executor ->query ($ query )->then (
519520 null ,
520- function ($ e ) use (&$ wait ) {
521- $ wait = false ;
522- throw $ e ;
521+ function ($ e ) use (&$ exception ) {
522+ $ exception = $ e ;
523523 }
524524 );
525525
526526 \Clue \React \Block \sleep (0.01 , $ loop );
527- if ($ wait ) {
527+ if ($ exception === null ) {
528528 \Clue \React \Block \sleep (0.2 , $ loop );
529529 }
530530
531- $ this ->assertFalse ($ wait );
531+ /** @var \RuntimeException $exception */
532+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
533+ $ this ->assertEquals ('DNS query for google.com (A) failed: Invalid message received from DNS server tcp:// ' . $ address , $ exception ->getMessage ());
532534 }
533535
534536 public function testQueryRejectsWhenServerSendsInvalidId ()
@@ -564,21 +566,22 @@ public function testQueryRejectsWhenServerSendsInvalidId()
564566
565567 $ query = new Query ('google.com ' , Message::TYPE_A , Message::CLASS_IN );
566568
567- $ wait = true ;
569+ $ exception = null ;
568570 $ executor ->query ($ query )->then (
569571 null ,
570- function ($ e ) use (&$ wait ) {
571- $ wait = false ;
572- throw $ e ;
572+ function ($ e ) use (&$ exception ) {
573+ $ exception = $ e ;
573574 }
574575 );
575576
576577 \Clue \React \Block \sleep (0.01 , $ loop );
577- if ($ wait ) {
578+ if ($ exception === null ) {
578579 \Clue \React \Block \sleep (0.2 , $ loop );
579580 }
580581
581- $ this ->assertFalse ($ wait );
582+ /** @var \RuntimeException $exception */
583+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
584+ $ this ->assertEquals ('DNS query for google.com (A) failed: Invalid response message received from DNS server tcp:// ' . $ address , $ exception ->getMessage ());
582585 }
583586
584587 public function testQueryRejectsIfServerSendsTruncatedResponse ()
@@ -614,21 +617,22 @@ public function testQueryRejectsIfServerSendsTruncatedResponse()
614617
615618 $ query = new Query ('google.com ' , Message::TYPE_A , Message::CLASS_IN );
616619
617- $ wait = true ;
620+ $ exception = null ;
618621 $ executor ->query ($ query )->then (
619622 null ,
620- function ($ e ) use (&$ wait ) {
621- $ wait = false ;
622- throw $ e ;
623+ function ($ e ) use (&$ exception ) {
624+ $ exception = $ e ;
623625 }
624626 );
625627
626628 \Clue \React \Block \sleep (0.01 , $ loop );
627- if ($ wait ) {
629+ if ($ exception === null ) {
628630 \Clue \React \Block \sleep (0.2 , $ loop );
629631 }
630632
631- $ this ->assertFalse ($ wait );
633+ /** @var \RuntimeException $exception */
634+ $ this ->assertInstanceOf ('RuntimeException ' , $ exception );
635+ $ this ->assertEquals ('DNS query for google.com (A) failed: Invalid response message received from DNS server tcp:// ' . $ address , $ exception ->getMessage ());
632636 }
633637
634638 public function testQueryResolvesIfServerSendsValidResponse ()
0 commit comments