1
0
mirror of https://github.com/danog/dns.git synced 2024-12-03 18:07:53 +01:00
dns/test/IntegrationTest.php

48 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2014-09-24 19:31:27 +02:00
namespace Amp\Dns\Test;
2014-09-23 22:47:55 +02:00
class IntegrationTest extends \PHPUnit_Framework_TestCase {
2015-08-02 04:18:44 +02:00
protected function setUp() {
\Amp\reactor(\Amp\driver());
}
/**
* @group internet
*/
2015-08-02 04:18:44 +02:00
public function testResolve() {
\Amp\run(function () {
$names = [
"google.com",
"github.com",
"stackoverflow.com",
"localhost",
"192.168.0.1",
"::1",
];
foreach ($names as $name) {
list($addr, $mode) = (yield \Amp\Dns\resolve($name));
$inAddr = @\inet_pton($addr);
$this->assertNotFalse(
$inAddr,
"Server name $name did not resolve to a valid IP address"
);
if (isset($inAddr[15])) {
$this->assertSame(
\Amp\Dns\MODE_INET6,
$mode,
"Returned mode parameter did not match expected MODE_INET6"
);
} else {
$this->assertSame(
\Amp\Dns\MODE_INET4,
$mode,
"Returned mode parameter did not match expected MODE_INET4"
);
}
}
});
}
}