1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Merge branch 'master' into amp_v2

This commit is contained in:
Niklas Keller 2017-01-25 16:36:19 +01:00
commit badf3a9100
2 changed files with 47 additions and 21 deletions

View File

@ -7,27 +7,53 @@ use AsyncInterop\Loop;
class IntegrationTest extends \PHPUnit_Framework_TestCase {
/**
* @group internet
* @dataProvider provideHostnames
*/
public function testResolve() {
Loop::execute(\Amp\wrap(function () {
$names = [
"google.com",
"github.com",
"stackoverflow.com",
"localhost",
"192.168.0.1",
"::1",
];
foreach ($names as $name) {
$result = (yield \Amp\Dns\resolve($name));
list($addr, $type, $ttl) = $result[0];
$inAddr = @\inet_pton($addr);
$this->assertNotFalse(
$inAddr,
"Server name $name did not resolve to a valid IP address"
);
}
public function testResolve($hostname) {
Loop::execute(\Amp\wrap(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::execute(\Amp\wrap(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"],
];
}
}