2016-12-30 04:16:14 +01:00
|
|
|
<?php
|
2015-12-23 16:47:49 +01:00
|
|
|
|
|
|
|
namespace Amp\Dns\Test;
|
|
|
|
|
2017-06-17 12:30:38 +02:00
|
|
|
use Amp\Dns\Config;
|
|
|
|
use Amp\Dns\ConfigException;
|
|
|
|
use Amp\Dns\UnixConfigLoader;
|
2017-06-17 10:49:54 +02:00
|
|
|
use Amp\PHPUnit\TestCase;
|
2017-06-17 12:30:38 +02:00
|
|
|
use function Amp\Promise\wait;
|
2016-03-19 22:23:55 +01:00
|
|
|
|
2017-06-17 10:49:54 +02:00
|
|
|
class ResolvConfTest extends TestCase {
|
2015-12-23 16:47:49 +01:00
|
|
|
public function test() {
|
2017-06-17 12:30:38 +02:00
|
|
|
$loader = new UnixConfigLoader(__DIR__ . "/data/resolv.conf");
|
2016-03-19 22:23:55 +01:00
|
|
|
|
2017-06-17 12:30:38 +02:00
|
|
|
/** @var Config $result */
|
|
|
|
$result = wait($loader->loadConfig());
|
2015-12-23 16:47:49 +01:00
|
|
|
|
|
|
|
$this->assertSame([
|
2017-06-17 12:30:38 +02:00
|
|
|
"127.0.0.1:53",
|
|
|
|
"[2001:4860:4860::8888]:53",
|
|
|
|
], $result->getNameservers());
|
|
|
|
|
|
|
|
$this->assertSame(5000, $result->getTimeout());
|
|
|
|
$this->assertSame(3, $result->getAttempts());
|
2015-12-23 16:47:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDefaultsOnConfNotFound() {
|
2017-06-17 12:30:38 +02:00
|
|
|
$this->expectException(ConfigException::class);
|
|
|
|
wait((new UnixConfigLoader(__DIR__ . "/data/non-existent.conf"))->loadConfig());
|
2015-12-23 16:47:49 +01:00
|
|
|
}
|
2017-06-17 10:49:54 +02:00
|
|
|
}
|