1
0
mirror of https://github.com/danog/dns.git synced 2024-11-27 04:24:48 +01:00
dns/test/ResolvConfTest.php

32 lines
851 B
PHP
Raw Normal View History

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