1
0
mirror of https://github.com/danog/dns.git synced 2024-12-12 09:29:46 +01:00
dns/test/UnixConfigLoaderTest.php

35 lines
867 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;
2019-01-25 02:27:47 +01:00
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());
}
2019-01-25 02:27:47 +01:00
public function testNoDefaultsOnConfNotFound()
{
$this->expectException(ConfigException::class);
wait((new UnixConfigLoader(__DIR__ . "/data/non-existent.conf"))->loadConfig());
}
2017-06-17 10:49:54 +02:00
}