diff --git a/lib/BasicResolver.php b/lib/BasicResolver.php index 455a643..3977266 100644 --- a/lib/BasicResolver.php +++ b/lib/BasicResolver.php @@ -88,6 +88,8 @@ class BasicResolver implements Resolver { $this->query($name, Record::A), $this->query($name, Record::AAAA), ]); + + $records = \array_merge(...$records); } catch (MultiReasonException $e) { foreach ($e->getReasons() as $reason) { if ($reason instanceof NoRecordException) { @@ -113,7 +115,7 @@ class BasicResolver implements Resolver { } } - return \array_merge(...$records); + return $records; }); } diff --git a/test/IntegrationTest.php b/test/IntegrationTest.php index 623f740..8ab8ad4 100644 --- a/test/IntegrationTest.php +++ b/test/IntegrationTest.php @@ -27,6 +27,38 @@ class IntegrationTest extends TestCase { }); } + public function testResolveIPv4only() { + Loop::run(function () { + $records = yield Dns\resolve("google.com", Record::A); + + /** @var Record $record */ + foreach ($records as $record) { + $this->assertSame(Record::A, $record->getType()); + $inAddr = @\inet_pton($record->getValue()); + $this->assertNotFalse( + $inAddr, + "Server name google.com did not resolve to a valid IP address" + ); + } + }); + } + + public function testResolveIPv6only() { + Loop::run(function () { + $records = yield Dns\resolve("google.com", Record::AAAA); + + /** @var Record $record */ + foreach ($records as $record) { + $this->assertSame(Record::AAAA, $record->getType()); + $inAddr = @\inet_pton($record->getValue()); + $this->assertNotFalse( + $inAddr, + "Server name google.com did not resolve to a valid IP address" + ); + } + }); + } + public function testPtrLookup() { Loop::run(function () { $result = yield Dns\query("8.8.4.4", Record::PTR);