1
0
mirror of https://github.com/danog/dns.git synced 2024-12-02 17:38:05 +01:00
dns/test/HostLoaderTest.php
2019-01-24 19:27:47 -06:00

44 lines
1.1 KiB
PHP

<?php
namespace Amp\Dns\Test;
use Amp\Dns\HostLoader;
use Amp\Dns\Record;
use Amp\Loop;
use Amp\PHPUnit\TestCase;
class HostLoaderTest extends TestCase
{
public function testIgnoresCommentsAndParsesBasicEntry()
{
Loop::run(function () {
$loader = new HostLoader(__DIR__ . "/data/hosts");
$this->assertSame([
Record::A => [
"localhost" => "127.0.0.1",
],
], yield $loader->loadHosts());
});
}
public function testReturnsEmptyErrorOnFileNotFound()
{
Loop::run(function () {
$loader = new HostLoader(__DIR__ . "/data/hosts.not.found");
$this->assertSame([], yield $loader->loadHosts());
});
}
public function testIgnoresInvalidNames()
{
Loop::run(function () {
$loader = new HostLoader(__DIR__ . "/data/hosts.invalid.name");
$this->assertSame([
Record::A => [
"localhost" => "127.0.0.1",
],
], yield $loader->loadHosts());
});
}
}