1
0
mirror of https://github.com/danog/dns.git synced 2025-01-23 05:51:11 +01:00
dns/test/IntegrationTest.php
2017-03-16 23:01:58 -05:00

60 lines
1.5 KiB
PHP

<?php
namespace Amp\Dns\Test;
use Amp\Loop;
class IntegrationTest extends \PHPUnit_Framework_TestCase {
/**
* @group internet
* @dataProvider provideHostnames
*/
public function testResolve($hostname) {
Loop::run(function () use ($hostname) {
$result = (yield \Amp\Dns\resolve($hostname));
list($addr, $type, $ttl) = $result[0];
$inAddr = @\inet_pton($addr);
$this->assertNotFalse(
$inAddr,
"Server name $hostname did not resolve to a valid IP address"
);
});
}
/**
* @group internet
* @dataProvider provideServers
*/
public function testResolveWithCustomServer($server) {
Loop::run(function () use ($server) {
$result = (yield \Amp\Dns\resolve("google.com", [
"server" => $server
]));
list($addr, $type, $ttl) = $result[0];
$inAddr = @\inet_pton($addr);
$this->assertNotFalse(
$inAddr,
"Server name google.com did not resolve to a valid IP address via $server"
);
});
}
public function provideHostnames() {
return [
["google.com"],
["github.com"],
["stackoverflow.com"],
["localhost"],
["192.168.0.1"],
["::1"],
];
}
public function provideServers() {
return [
["8.8.8.8"],
["8.8.8.8:53"],
];
}
}