1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00
dns/test/UnixConfigLoaderTest.php
2017-06-22 19:26:41 +02:00

32 lines
859 B
PHP

<?php
namespace Amp\Dns\Test;
use Amp\Dns\Config;
use Amp\Dns\ConfigException;
use Amp\Dns\UnixConfigLoader;
use Amp\PHPUnit\TestCase;
use function Amp\Promise\wait;
class UnixConfigLoaderTest 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 testNoDefaultsOnConfNotFound() {
$this->expectException(ConfigException::class);
wait((new UnixConfigLoader(__DIR__ . "/data/non-existent.conf"))->loadConfig());
}
}