2016-12-30 04:16:14 +01:00
|
|
|
<?php
|
2015-12-23 16:47:49 +01:00
|
|
|
|
|
|
|
namespace Amp\Dns\Test;
|
|
|
|
|
2016-08-02 23:57:40 +02:00
|
|
|
use Amp\Coroutine;
|
2016-03-19 22:23:55 +01:00
|
|
|
use ReflectionObject;
|
|
|
|
|
2015-12-23 16:47:49 +01:00
|
|
|
class ResolvConfTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
public function test() {
|
2016-03-19 22:23:55 +01:00
|
|
|
$reflector = new ReflectionObject(\Amp\Dns\resolver());
|
|
|
|
$method = $reflector->getMethod("loadResolvConf");
|
|
|
|
$method->setAccessible(true);
|
|
|
|
|
2016-08-02 23:57:40 +02:00
|
|
|
$result = \Amp\wait(new Coroutine($method->invoke(\Amp\Dns\resolver(), __DIR__ . "/data/resolv.conf")));
|
2015-12-23 16:47:49 +01:00
|
|
|
|
|
|
|
$this->assertSame([
|
|
|
|
"nameservers" => [
|
|
|
|
"127.0.0.1:53",
|
|
|
|
"[2001:4860:4860::8888]:53"
|
|
|
|
],
|
|
|
|
"timeout" => 5000,
|
|
|
|
"attempts" => 3,
|
|
|
|
], $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDefaultsOnConfNotFound() {
|
2016-03-19 22:23:55 +01:00
|
|
|
$reflector = new ReflectionObject(\Amp\Dns\resolver());
|
|
|
|
$method = $reflector->getMethod("loadResolvConf");
|
|
|
|
$method->setAccessible(true);
|
|
|
|
|
2016-08-02 23:57:40 +02:00
|
|
|
$result = \Amp\wait(new Coroutine($method->invoke(\Amp\Dns\resolver(), __DIR__ . "/data/invalid.conf")));
|
2015-12-23 16:47:49 +01:00
|
|
|
|
|
|
|
$this->assertSame([
|
|
|
|
"nameservers" => [
|
|
|
|
"8.8.8.8:53",
|
|
|
|
"8.8.4.4:53"
|
|
|
|
],
|
|
|
|
"timeout" => 3000,
|
|
|
|
"attempts" => 2,
|
|
|
|
], $result);
|
|
|
|
}
|
|
|
|
}
|