@@ -178,7 +178,7 @@ public function createWithConfigWithTcpNameserverSchemeShouldCreateResolverWithT
178178 }
179179
180180 /** @test */
181- public function createWithConfigWithMultipleWithTcpSchemeShouldCreateResolverWithTcpExecutorStack ()
181+ public function createWithConfigWithTwoNameserversWithTcpSchemeShouldCreateResolverWithFallbackExecutorStack ()
182182 {
183183 $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
184184
@@ -244,6 +244,98 @@ public function createWithConfigWithMultipleWithTcpSchemeShouldCreateResolverWit
244244 $ this ->assertEquals ('tcp://1.1.1.1:53 ' , $ nameserver );
245245 }
246246
247+ /** @test */
248+ public function createWithConfigWithThreeNameserversWithTcpSchemeShouldCreateResolverWithNestedFallbackExecutorStack ()
249+ {
250+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
251+
252+ $ config = new Config ();
253+ $ config ->nameservers [] = 'tcp://8.8.8.8:53 ' ;
254+ $ config ->nameservers [] = 'tcp://1.1.1.1:53 ' ;
255+ $ config ->nameservers [] = 'tcp://9.9.9.9:53 ' ;
256+
257+ $ factory = new Factory ();
258+ $ resolver = $ factory ->create ($ config , $ loop );
259+
260+ $ this ->assertInstanceOf ('React\Dns\Resolver\Resolver ' , $ resolver );
261+
262+ $ coopExecutor = $ this ->getResolverPrivateExecutor ($ resolver );
263+
264+ $ this ->assertInstanceOf ('React\Dns\Query\CoopExecutor ' , $ coopExecutor );
265+
266+ $ ref = new \ReflectionProperty ($ coopExecutor , 'executor ' );
267+ $ ref ->setAccessible (true );
268+ $ retryExecutor = $ ref ->getValue ($ coopExecutor );
269+
270+ $ this ->assertInstanceOf ('React\Dns\Query\RetryExecutor ' , $ retryExecutor );
271+
272+ $ ref = new \ReflectionProperty ($ retryExecutor , 'executor ' );
273+ $ ref ->setAccessible (true );
274+ $ fallbackExecutor = $ ref ->getValue ($ retryExecutor );
275+
276+ $ this ->assertInstanceOf ('React\Dns\Query\FallbackExecutor ' , $ fallbackExecutor );
277+
278+ $ ref = new \ReflectionProperty ($ fallbackExecutor , 'executor ' );
279+ $ ref ->setAccessible (true );
280+ $ timeoutExecutor = $ ref ->getValue ($ fallbackExecutor );
281+
282+ $ this ->assertInstanceOf ('React\Dns\Query\TimeoutExecutor ' , $ timeoutExecutor );
283+
284+ $ ref = new \ReflectionProperty ($ timeoutExecutor , 'executor ' );
285+ $ ref ->setAccessible (true );
286+ $ tcpExecutor = $ ref ->getValue ($ timeoutExecutor );
287+
288+ $ this ->assertInstanceOf ('React\Dns\Query\TcpTransportExecutor ' , $ tcpExecutor );
289+
290+ $ ref = new \ReflectionProperty ($ tcpExecutor , 'nameserver ' );
291+ $ ref ->setAccessible (true );
292+ $ nameserver = $ ref ->getValue ($ tcpExecutor );
293+
294+ $ this ->assertEquals ('tcp://8.8.8.8:53 ' , $ nameserver );
295+
296+ $ ref = new \ReflectionProperty ($ fallbackExecutor , 'fallback ' );
297+ $ ref ->setAccessible (true );
298+ $ fallbackExecutor = $ ref ->getValue ($ fallbackExecutor );
299+
300+ $ this ->assertInstanceOf ('React\Dns\Query\FallbackExecutor ' , $ fallbackExecutor );
301+
302+ $ ref = new \ReflectionProperty ($ fallbackExecutor , 'executor ' );
303+ $ ref ->setAccessible (true );
304+ $ timeoutExecutor = $ ref ->getValue ($ fallbackExecutor );
305+
306+ $ this ->assertInstanceOf ('React\Dns\Query\TimeoutExecutor ' , $ timeoutExecutor );
307+
308+ $ ref = new \ReflectionProperty ($ timeoutExecutor , 'executor ' );
309+ $ ref ->setAccessible (true );
310+ $ tcpExecutor = $ ref ->getValue ($ timeoutExecutor );
311+
312+ $ this ->assertInstanceOf ('React\Dns\Query\TcpTransportExecutor ' , $ tcpExecutor );
313+
314+ $ ref = new \ReflectionProperty ($ tcpExecutor , 'nameserver ' );
315+ $ ref ->setAccessible (true );
316+ $ nameserver = $ ref ->getValue ($ tcpExecutor );
317+
318+ $ this ->assertEquals ('tcp://1.1.1.1:53 ' , $ nameserver );
319+
320+ $ ref = new \ReflectionProperty ($ fallbackExecutor , 'fallback ' );
321+ $ ref ->setAccessible (true );
322+ $ timeoutExecutor = $ ref ->getValue ($ fallbackExecutor );
323+
324+ $ this ->assertInstanceOf ('React\Dns\Query\TimeoutExecutor ' , $ timeoutExecutor );
325+
326+ $ ref = new \ReflectionProperty ($ timeoutExecutor , 'executor ' );
327+ $ ref ->setAccessible (true );
328+ $ tcpExecutor = $ ref ->getValue ($ timeoutExecutor );
329+
330+ $ this ->assertInstanceOf ('React\Dns\Query\TcpTransportExecutor ' , $ tcpExecutor );
331+
332+ $ ref = new \ReflectionProperty ($ tcpExecutor , 'nameserver ' );
333+ $ ref ->setAccessible (true );
334+ $ nameserver = $ ref ->getValue ($ tcpExecutor );
335+
336+ $ this ->assertEquals ('tcp://9.9.9.9:53 ' , $ nameserver );
337+ }
338+
247339 /** @test */
248340 public function createShouldThrowWhenNameserverIsInvalid ()
249341 {
0 commit comments