@@ -107,34 +107,63 @@ public function testResolveAllGoogleCaaResolvesWithCache()
107107 */
108108 public function testResolveInvalidRejects ()
109109 {
110- $ ex = $ this ->callback (function ($ param ) {
111- return ($ param instanceof RecordNotFoundException && $ param ->getCode () === Message::RCODE_NAME_ERROR );
112- });
113-
114110 $ promise = $ this ->resolver ->resolve ('example.invalid ' );
115- $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnceWith ($ ex ));
116111
117112 $ this ->loop ->run ();
113+
114+ $ exception = null ;
115+ $ promise ->then (null , function ($ reason ) use (&$ exception ) {
116+ $ exception = $ reason ;
117+ });
118+
119+ /** @var \React\Dns\RecordNotFoundException $exception */
120+ $ this ->assertInstanceOf ('React\Dns\RecordNotFoundException ' , $ exception );
121+ $ this ->assertEquals ('DNS query for example.invalid (A) returned an error response (Non-Existent Domain / NXDOMAIN) ' , $ exception ->getMessage ());
122+ $ this ->assertEquals (Message::RCODE_NAME_ERROR , $ exception ->getCode ());
118123 }
119124
120125 public function testResolveCancelledRejectsImmediately ()
121126 {
122127 // max_nesting_level was set to 100 for PHP Versions < 5.4 which resulted in failing test for legacy PHP
123128 ini_set ('xdebug.max_nesting_level ' , 256 );
124129
125- $ ex = $ this ->callback (function ($ param ) {
126- return ($ param instanceof \RuntimeException && $ param ->getMessage () === 'DNS query for google.com has been cancelled ' );
127- });
128-
129130 $ promise = $ this ->resolver ->resolve ('google.com ' );
130- $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnceWith ($ ex ));
131131 $ promise ->cancel ();
132132
133133 $ time = microtime (true );
134134 $ this ->loop ->run ();
135135 $ time = microtime (true ) - $ time ;
136136
137137 $ this ->assertLessThan (0.1 , $ time );
138+
139+ $ exception = null ;
140+ $ promise ->then (null , function ($ reason ) use (&$ exception ) {
141+ $ exception = $ reason ;
142+ });
143+
144+ /** @var \React\Dns\Query\CancellationException $exception */
145+ $ this ->assertInstanceOf ('React\Dns\Query\CancellationException ' , $ exception );
146+ $ this ->assertEquals ('DNS query for google.com (A) has been cancelled ' , $ exception ->getMessage ());
147+ }
148+
149+ /**
150+ * @group internet
151+ */
152+ public function testResolveAllInvalidTypeRejects ()
153+ {
154+ $ promise = $ this ->resolver ->resolveAll ('google.com ' , Message::TYPE_PTR );
155+
156+ $ this ->loop ->run ();
157+
158+ $ exception = null ;
159+ $ promise ->then (null , function ($ reason ) use (&$ exception ) {
160+ $ exception = $ reason ;
161+ });
162+
163+ /** @var \React\Dns\RecordNotFoundException $exception */
164+ $ this ->assertInstanceOf ('React\Dns\RecordNotFoundException ' , $ exception );
165+ $ this ->assertEquals ('DNS query for google.com (PTR) did not return a valid answer (NOERROR / NODATA) ' , $ exception ->getMessage ());
166+ $ this ->assertEquals (0 , $ exception ->getCode ());
138167 }
139168
140169 public function testInvalidResolverDoesNotResolveGoogle ()
0 commit comments